Skip to content

Commit 4dc8d17

Browse files
committed
[FOLD] remove redundant calls to ActOnDependentIdExpression
1 parent 90b2e4b commit 4dc8d17

File tree

2 files changed

+9
-34
lines changed

2 files changed

+9
-34
lines changed

clang/lib/Sema/SemaExpr.cpp

+3-31
Original file line numberDiff line numberDiff line change
@@ -2718,34 +2718,6 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
27182718
return ExprError();
27192719
}
27202720

2721-
// C++ [temp.dep.expr]p3:
2722-
// An id-expression is type-dependent if it contains:
2723-
// -- an identifier that was declared with a dependent type,
2724-
// (note: handled after lookup)
2725-
// -- a template-id that is dependent,
2726-
// (note: handled in BuildTemplateIdExpr)
2727-
// -- a conversion-function-id that specifies a dependent type,
2728-
// -- a nested-name-specifier that contains a class-name that
2729-
// names a dependent type.
2730-
// Determine whether this is a member of an unknown specialization;
2731-
// we need to handle these differently.
2732-
bool DependentID = false;
2733-
if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName &&
2734-
Name.getCXXNameType()->isDependentType()) {
2735-
DependentID = true;
2736-
} else if (SS.isSet()) {
2737-
if (DeclContext *DC = computeDeclContext(SS, false)) {
2738-
if (RequireCompleteDeclContext(SS, DC))
2739-
return ExprError();
2740-
} else {
2741-
DependentID = true;
2742-
}
2743-
}
2744-
2745-
if (DependentID)
2746-
return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2747-
IsAddressOfOperand, TemplateArgs);
2748-
27492721
// BoundsSafety: This specially handles arguments of bounds attributes
27502722
// appertains to a type of C struct field such that the name lookup
27512723
// within a struct finds the member name, which is not the case for other
@@ -2781,7 +2753,7 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
27812753
&AssumedTemplate))
27822754
return ExprError();
27832755

2784-
if (R.wasNotFoundInCurrentInstantiation())
2756+
if (R.wasNotFoundInCurrentInstantiation() || SS.isInvalid())
27852757
return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
27862758
IsAddressOfOperand, TemplateArgs);
27872759
} else {
@@ -2791,7 +2763,7 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
27912763

27922764
// If the result might be in a dependent base class, this is a dependent
27932765
// id-expression.
2794-
if (R.wasNotFoundInCurrentInstantiation())
2766+
if (R.wasNotFoundInCurrentInstantiation() || SS.isInvalid())
27952767
return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
27962768
IsAddressOfOperand, TemplateArgs);
27972769

@@ -3177,7 +3149,7 @@ bool Sema::UseArgumentDependentLookup(const CXXScopeSpec &SS,
31773149
return false;
31783150

31793151
// Never if a scope specifier was provided.
3180-
if (SS.isSet())
3152+
if (SS.isNotEmpty())
31813153
return false;
31823154

31833155
// Only in C++ or ObjC++.

clang/lib/Sema/SemaLookup.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -2771,16 +2771,19 @@ bool Sema::LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
27712771
ObjectType->castAs<TagType>()->isBeingDefined()) &&
27722772
"Caller should have completed object type");
27732773
} else if (SS && SS->isNotEmpty()) {
2774-
if (NestedNameSpecifier *NNS = SS->getScopeRep();
2775-
NNS->getKind() == NestedNameSpecifier::Super)
2776-
return LookupInSuper(R, NNS->getAsRecordDecl());
27772774
// This nested-name-specifier occurs after another nested-name-specifier,
27782775
// so long into the context associated with the prior nested-name-specifier.
27792776
if ((DC = computeDeclContext(*SS, EnteringContext))) {
27802777
// The declaration context must be complete.
27812778
if (!DC->isDependentContext() && RequireCompleteDeclContext(*SS, DC))
27822779
return false;
27832780
R.setContextRange(SS->getRange());
2781+
// FIXME: '__super' lookup semantics could be implemented by a
2782+
// LookupResult::isSuperLookup flag which skips the initial search of
2783+
// the lookup context in LookupQualified.
2784+
if (NestedNameSpecifier *NNS = SS->getScopeRep();
2785+
NNS->getKind() == NestedNameSpecifier::Super)
2786+
return LookupInSuper(R, NNS->getAsRecordDecl());
27842787
}
27852788
IsDependent = !DC && isDependentScopeSpecifier(*SS);
27862789
} else {

0 commit comments

Comments
 (0)