Skip to content

Commit fdc7dee

Browse files
committed
[FOLD]
1 parent aa41e28 commit fdc7dee

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9152,6 +9152,12 @@ class Sema final {
91529152
bool EnteringContext, bool &MemberOfUnknownSpecialization,
91539153
RequiredTemplateKind RequiredTemplate = SourceLocation(),
91549154
AssumedTemplateKind *ATK = nullptr, bool AllowTypoCorrection = true);
9155+
9156+
bool LookupTemplateName(
9157+
LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType,
9158+
bool EnteringContext,
9159+
RequiredTemplateKind RequiredTemplate = SourceLocation(),
9160+
AssumedTemplateKind *ATK = nullptr, bool AllowTypoCorrection = true);
91559161

91569162
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS,
91579163
bool hasTemplateKeyword,

clang/lib/Sema/SemaLookup.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,19 +2722,19 @@ bool Sema::LookupParsedName(LookupResult &R,
27222722
QualType ObjectType,
27232723
bool AllowBuiltinCreation,
27242724
bool EnteringContext) {
2725-
if (SS && SS->isInvalid()) {
2726-
// When the scope specifier is invalid, don't even look for
2727-
// anything.
2725+
// When the scope specifier is invalid, don't even look for anything.
2726+
if (SS && SS->isInvalid())
27282727
return false;
2729-
}
27302728

27312729
// Determine where to perform name lookup
27322730
DeclContext *DC = nullptr;
2731+
bool IsDependent = false;
27332732
if (!ObjectType.isNull()) {
27342733
// This nested-name-specifier occurs in a member access expression, e.g.,
27352734
// x->B::f, and we are looking into the type of the object.
27362735
assert((!SS || SS->isEmpty()) && "ObjectType and scope specifier cannot coexist");
27372736
DC = computeDeclContext(ObjectType);
2737+
IsDependent = !DC && ObjectType->isDependentType();
27382738
assert(((!DC && ObjectType->isDependentType()) ||
27392739
!ObjectType->isIncompleteType() ||
27402740
!ObjectType->getAs<TagType>() ||
@@ -2752,6 +2752,7 @@ bool Sema::LookupParsedName(LookupResult &R,
27522752
return false;
27532753
R.setContextRange(SS->getRange());
27542754
}
2755+
IsDependent = !DC && isDependentScopeSpecifier(*SS);
27552756
} else {
27562757
// Perform unqualified name lookup starting in the given scope.
27572758
return LookupName(R, S, AllowBuiltinCreation);
@@ -2761,11 +2762,11 @@ bool Sema::LookupParsedName(LookupResult &R,
27612762
// lookup in that context.
27622763
if (DC)
27632764
return LookupQualifiedName(R, DC);
2764-
2765-
// We could not resolve the scope specified to a specific declaration
2766-
// context, which means that SS refers to an unknown specialization.
2767-
// Name lookup can't find anything in this case.
2768-
R.setNotFoundInCurrentInstantiation();
2765+
else if (IsDependent)
2766+
// We could not resolve the scope specified to a specific declaration
2767+
// context, which means that SS refers to an unknown specialization.
2768+
// Name lookup can't find anything in this case.
2769+
R.setNotFoundInCurrentInstantiation();
27692770
return false;
27702771
}
27712772

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,12 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
319319
bool Sema::isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
320320
SourceLocation NameLoc, CXXScopeSpec &SS,
321321
ParsedTemplateTy *Template /*=nullptr*/) {
322-
bool MemberOfUnknownSpecialization = false;
323-
324322
// We could use redeclaration lookup here, but we don't need to: the
325323
// syntactic form of a deduction guide is enough to identify it even
326324
// if we can't look up the template name at all.
327325
LookupResult R(*this, DeclarationName(&Name), NameLoc, LookupOrdinaryName);
328326
if (LookupTemplateName(R, S, SS, /*ObjectType*/ QualType(),
329-
/*EnteringContext*/ false,
330-
MemberOfUnknownSpecialization))
327+
/*EnteringContext*/ false))
331328
return false;
332329

333330
if (R.empty()) return false;
@@ -373,6 +370,19 @@ bool Sema::DiagnoseUnknownTemplateName(const IdentifierInfo &II,
373370
return true;
374371
}
375372

373+
bool Sema::LookupTemplateName(LookupResult &Found,
374+
Scope *S, CXXScopeSpec &SS,
375+
QualType ObjectType,
376+
bool EnteringContext,
377+
RequiredTemplateKind RequiredTemplate,
378+
AssumedTemplateKind *ATK,
379+
bool AllowTypoCorrection) {
380+
bool MemberOfUnknownSpecialization;
381+
return LookupTemplateName(Found, S, SS, ObjectType, EnteringContext,
382+
MemberOfUnknownSpecialization, RequiredTemplate,
383+
ATK, AllowTypoCorrection);
384+
}
385+
376386
bool Sema::LookupTemplateName(LookupResult &Found,
377387
Scope *S, CXXScopeSpec &SS,
378388
QualType ObjectType,
@@ -5475,10 +5485,9 @@ Sema::BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
54755485
RequireCompleteDeclContext(SS, DC))
54765486
return BuildDependentDeclRefExpr(SS, TemplateKWLoc, NameInfo, TemplateArgs);
54775487

5478-
bool MemberOfUnknownSpecialization;
54795488
LookupResult R(*this, NameInfo, LookupOrdinaryName);
54805489
if (LookupTemplateName(R, (Scope *)nullptr, SS, QualType(),
5481-
/*Entering*/false, MemberOfUnknownSpecialization,
5490+
/*Entering*/false,
54825491
TemplateKWLoc))
54835492
return ExprError();
54845493

@@ -5600,14 +5609,13 @@ TemplateNameKind Sema::ActOnTemplateName(Scope *S,
56005609
DeclarationNameInfo DNI = GetNameFromUnqualifiedId(Name);
56015610
LookupResult R(*this, DNI.getName(), Name.getBeginLoc(),
56025611
LookupOrdinaryName);
5603-
bool MOUS;
56045612
// Tell LookupTemplateName that we require a template so that it diagnoses
56055613
// cases where it finds a non-template.
56065614
RequiredTemplateKind RTK = TemplateKWLoc.isValid()
56075615
? RequiredTemplateKind(TemplateKWLoc)
56085616
: TemplateNameIsRequired;
5609-
if (!LookupTemplateName(R, S, SS, ObjectType.get(), EnteringContext, MOUS,
5610-
RTK, nullptr, /*AllowTypoCorrection=*/false) &&
5617+
if (!LookupTemplateName(R, S, SS, ObjectType.get(), EnteringContext,
5618+
RTK, /*ATK=*/nullptr, /*AllowTypoCorrection=*/false) &&
56115619
!R.isAmbiguous()) {
56125620
if (LookupCtx)
56135621
Diag(Name.getBeginLoc(), diag::err_no_member)

0 commit comments

Comments
 (0)