Skip to content

Commit b68ea7b

Browse files
committed
[FOLD]
1 parent 4dbbfdd commit b68ea7b

File tree

4 files changed

+19
-75
lines changed

4 files changed

+19
-75
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7018,8 +7018,8 @@ class Sema final : public SemaBase {
70187018
///@{
70197019

70207020
public:
7021-
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS,
7022-
LookupResult &R,
7021+
/// Check whether an expression might be an implicit class member access.
7022+
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R,
70237023
bool IsAddressOfOperand);
70247024

70257025
ExprResult BuildPossibleImplicitMemberExpr(

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2912,32 +2912,9 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
29122912
// to get this right here so that we don't end up making a
29132913
// spuriously dependent expression if we're inside a dependent
29142914
// instance method.
2915-
#if 0
2916-
if (getLangOpts().CPlusPlus && !R.empty() &&
2917-
(*R.begin())->isCXXClassMember()) {
2918-
bool MightBeImplicitMember;
2919-
if (!IsAddressOfOperand)
2920-
MightBeImplicitMember = true;
2921-
else if (!SS.isEmpty())
2922-
MightBeImplicitMember = false;
2923-
else if (R.isOverloadedResult())
2924-
MightBeImplicitMember = false;
2925-
else if (R.isUnresolvableResult())
2926-
MightBeImplicitMember = true;
2927-
else
2928-
MightBeImplicitMember = isa<FieldDecl>(R.getFoundDecl()) ||
2929-
isa<IndirectFieldDecl>(R.getFoundDecl()) ||
2930-
isa<MSPropertyDecl>(R.getFoundDecl());
2931-
2932-
if (MightBeImplicitMember)
2933-
return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2934-
R, TemplateArgs, S);
2935-
}
2936-
#else
29372915
if (isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
2938-
return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2939-
R, TemplateArgs, S);
2940-
#endif
2916+
return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R, TemplateArgs,
2917+
S);
29412918

29422919
if (TemplateArgs || TemplateKWLoc.isValid()) {
29432920

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8644,7 +8644,7 @@ static ExprResult attemptRecovery(Sema &SemaRef,
86448644
// Detect and handle the case where the decl might be an implicit
86458645
// member.
86468646
if (SemaRef.isPotentialImplicitMemberAccess(
8647-
NewSS, R, Consumer.isAddressOfOperand()))
8647+
NewSS, R, Consumer.isAddressOfOperand()))
86488648
return SemaRef.BuildPossibleImplicitMemberExpr(
86498649
NewSS, /*TemplateKWLoc*/ SourceLocation(), R,
86508650
/*TemplateArgs*/ nullptr, /*S*/ nullptr);

clang/lib/Sema/TreeTransform.h

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13068,48 +13068,8 @@ TreeTransform<Derived>::TransformUnresolvedLookupExpr(UnresolvedLookupExpr *Old,
1306813068
R.setNamingClass(NamingClass);
1306913069
}
1307013070

13071+
// Rebuild the template arguments, if any.
1307113072
SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
13072-
13073-
#if 0
13074-
// If we have neither explicit template arguments, nor the template keyword,
13075-
// it's a normal declaration name or member reference.
13076-
if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) {
13077-
NamedDecl *D = R.getAsSingle<NamedDecl>();
13078-
// In a C++11 unevaluated context, an UnresolvedLookupExpr might refer to an
13079-
// instance member. In other contexts, BuildPossibleImplicitMemberExpr will
13080-
// give a good diagnostic.
13081-
if (D && D->isCXXInstanceMember()) {
13082-
return SemaRef.BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R,
13083-
/*TemplateArgs=*/nullptr,
13084-
/*Scope=*/nullptr);
13085-
}
13086-
13087-
return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
13088-
}
13089-
#endif
13090-
13091-
bool PotentiallyImplicitAccess =
13092-
#if 0
13093-
R.isClassLookup() &&
13094-
(!IsAddressOfOperand ||
13095-
(R.isSingleResult() &&
13096-
R.getAsSingle<NamedDecl>()->isCXXInstanceMember()));
13097-
#elif 0
13098-
!IsAddressOfOperand && !R.empty() && R.begin()->isCXXClassMember();
13099-
#elif 1
13100-
SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand);
13101-
#endif
13102-
13103-
13104-
// If we have neither explicit template arguments, nor the template keyword,
13105-
// it's a normal declaration name or member reference.
13106-
if (!PotentiallyImplicitAccess && !Old->hasExplicitTemplateArgs() &&
13107-
!TemplateKWLoc.isValid()) {
13108-
return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
13109-
}
13110-
13111-
// If we have template arguments, rebuild them, then rebuild the
13112-
// templateid expression.
1311313073
TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
1311413074
if (Old->hasExplicitTemplateArgs() &&
1311513075
getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
@@ -13119,16 +13079,23 @@ TreeTransform<Derived>::TransformUnresolvedLookupExpr(UnresolvedLookupExpr *Old,
1311913079
return ExprError();
1312013080
}
1312113081

13122-
// In a C++11 unevaluated context, an UnresolvedLookupExpr might refer to an
13123-
// instance member. In other contexts, BuildPossibleImplicitMemberExpr will
13124-
// give a good diagnostic.
13125-
if (PotentiallyImplicitAccess) {
13082+
// An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
13083+
// a non-static data member is named in an unevaluated operand, or when
13084+
// a member is named in a dependent class scope function template explicit
13085+
// specialization that is neither declared static nor with an explicit object
13086+
// parameter.
13087+
if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
1312613088
return SemaRef.BuildPossibleImplicitMemberExpr(
1312713089
SS, TemplateKWLoc, R,
1312813090
Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
13129-
/*Scope=*/nullptr);
13130-
}
13091+
/*S=*/nullptr);
13092+
13093+
// If we have neither explicit template arguments, nor the template keyword,
13094+
// it's a normal declaration name or member reference.
13095+
if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
13096+
return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
1313113097

13098+
// If we have template arguments, then rebuild the template-id expression.
1313213099
return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
1313313100
Old->requiresADL(), &TransArgs);
1313413101
}

0 commit comments

Comments
 (0)