Skip to content

Commit 4cdb2b4

Browse files
committed
[FOLD] use IsDependent output parameter
1 parent 8e39f01 commit 4cdb2b4

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10640,7 +10640,8 @@ class Sema final : public SemaBase {
1064010640
/// (if one exists), where @c Base is an expression of class type and
1064110641
/// @c Member is the name of the member we're trying to find.
1064210642
ExprResult BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
10643-
bool *NoArrowOperatorFound = nullptr);
10643+
bool *NoArrowOperatorFound,
10644+
bool &IsDependent);
1064410645

1064510646
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl,
1064610647
CXXConversionDecl *Method,

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7979,6 +7979,7 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
79797979
return ExprError();
79807980
}
79817981

7982+
bool IsDependent;
79827983
Result = BuildOverloadedArrowExpr(
79837984
Base, OpLoc,
79847985
// When in a template specialization and on the first loop iteration,
@@ -7987,7 +7988,17 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
79877988
// and giving a diagnostic with a fixit attached to the error itself.
79887989
(FirstIteration && CurFD && CurFD->isFunctionTemplateSpecialization())
79897990
? nullptr
7990-
: &NoArrowOperatorFound);
7991+
: &NoArrowOperatorFound,
7992+
IsDependent);
7993+
7994+
if (IsDependent) {
7995+
// BuildOverloadedArrowExpr sets IsDependent to indicate that we need
7996+
// to build a dependent overloaded arrow expression.
7997+
assert(BaseType->isDependentType());
7998+
BaseType = Context.DependentTy;
7999+
break;
8000+
}
8001+
79918002
if (Result.isInvalid()) {
79928003
if (NoArrowOperatorFound) {
79938004
if (FirstIteration) {
@@ -8006,12 +8017,6 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
80068017
}
80078018
}
80088019
return ExprError();
8009-
} else if (Result.isUnset()) {
8010-
// BuildOverloadedArrowExpr returns an empty expression to indicate
8011-
// that we need to build a dependent overloaded arrow expression.
8012-
assert(BaseType->isDependentType());
8013-
BaseType = Context.DependentTy;
8014-
break;
80158020
}
80168021

80178022
Base = Result.get();

clang/lib/Sema/SemaOverload.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15877,10 +15877,13 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
1587715877
}
1587815878

1587915879
ExprResult Sema::BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
15880-
bool *NoArrowOperatorFound) {
15880+
bool *NoArrowOperatorFound,
15881+
bool &IsDependent) {
1588115882
assert(Base->getType()->getAsRecordDecl() &&
1588215883
"left-hand side must have class type");
1588315884

15885+
IsDependent = false;
15886+
1588415887
if (checkPlaceholderForOverload(*this, Base))
1588515888
return ExprError();
1588615889

@@ -15903,9 +15906,16 @@ ExprResult Sema::BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
1590315906
LookupResult R(*this, OpName, OpLoc, LookupOrdinaryName);
1590415907
LookupParsedName(R, /*S=*/nullptr, /*SS=*/nullptr, Base->getType());
1590515908

15909+
// If the expression is dependent and we either:
15910+
// - Found a member of the current instantiation named 'operator->', or
15911+
// - Found nothing, and the lookup context has no dependent base classes
15912+
//
15913+
// Then we should build a dependent class member access expression.
1590615914
if (R.wasNotFoundInCurrentInstantiation() ||
15907-
(Base->isTypeDependent() && !R.empty()))
15908-
return ExprEmpty();
15915+
(Base->isTypeDependent() && !R.empty())) {
15916+
IsDependent = true;
15917+
return Base;
15918+
}
1590915919

1591015920
R.suppressAccessDiagnostics();
1591115921

clang/lib/Sema/TreeTransform.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16567,8 +16567,12 @@ ExprResult TreeTransform<Derived>::RebuildCXXOperatorCallExpr(
1656716567
// in the tree transformation.
1656816568
if (First->containsErrors())
1656916569
return ExprError();
16570+
bool IsDependent;
1657016571
// -> is never a builtin operation.
16571-
return SemaRef.BuildOverloadedArrowExpr(First, OpLoc);
16572+
ExprResult Result = SemaRef.BuildOverloadedArrowExpr(
16573+
First, OpLoc, /*NoArrowOperatorFound=*/nullptr, IsDependent);
16574+
assert(!IsDependent);
16575+
return Result;
1657216576
} else if (Second == nullptr || isPostIncDec) {
1657316577
if (!First->getType()->isOverloadableType() ||
1657416578
(Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {

0 commit comments

Comments
 (0)