Skip to content

Commit 29282d2

Browse files
committed
[FOLD] use IsDependent output parameter
1 parent 0211427 commit 29282d2

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
@@ -7990,6 +7990,7 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
79907990
return ExprError();
79917991
}
79927992

7993+
bool IsDependent;
79937994
Result = BuildOverloadedArrowExpr(
79947995
Base, OpLoc,
79957996
// When in a template specialization and on the first loop iteration,
@@ -7998,7 +7999,17 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
79987999
// and giving a diagnostic with a fixit attached to the error itself.
79998000
(FirstIteration && CurFD && CurFD->isFunctionTemplateSpecialization())
80008001
? nullptr
8001-
: &NoArrowOperatorFound);
8002+
: &NoArrowOperatorFound,
8003+
IsDependent);
8004+
8005+
if (IsDependent) {
8006+
// BuildOverloadedArrowExpr sets IsDependent to indicate that we need
8007+
// to build a dependent overloaded arrow expression.
8008+
assert(BaseType->isDependentType());
8009+
BaseType = Context.DependentTy;
8010+
break;
8011+
}
8012+
80028013
if (Result.isInvalid()) {
80038014
if (NoArrowOperatorFound) {
80048015
if (FirstIteration) {
@@ -8017,12 +8028,6 @@ ExprResult Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base,
80178028
}
80188029
}
80198030
return ExprError();
8020-
} else if (Result.isUnset()) {
8021-
// BuildOverloadedArrowExpr returns an empty expression to indicate
8022-
// that we need to build a dependent overloaded arrow expression.
8023-
assert(BaseType->isDependentType());
8024-
BaseType = Context.DependentTy;
8025-
break;
80268031
}
80278032

80288033
Base = Result.get();

clang/lib/Sema/SemaOverload.cpp

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

1588115881
ExprResult Sema::BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
15882-
bool *NoArrowOperatorFound) {
15882+
bool *NoArrowOperatorFound,
15883+
bool &IsDependent) {
1588315884
assert(Base->getType()->getAsRecordDecl() &&
1588415885
"left-hand side must have class type");
1588515886

15887+
IsDependent = false;
15888+
1588615889
if (checkPlaceholderForOverload(*this, Base))
1588715890
return ExprError();
1588815891

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

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

1591215922
R.suppressAccessDiagnostics();
1591315923

clang/lib/Sema/TreeTransform.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16585,8 +16585,12 @@ ExprResult TreeTransform<Derived>::RebuildCXXOperatorCallExpr(
1658516585
// in the tree transformation.
1658616586
if (First->containsErrors())
1658716587
return ExprError();
16588+
bool IsDependent;
1658816589
// -> is never a builtin operation.
16589-
return SemaRef.BuildOverloadedArrowExpr(First, OpLoc);
16590+
ExprResult Result = SemaRef.BuildOverloadedArrowExpr(
16591+
First, OpLoc, /*NoArrowOperatorFound=*/nullptr, IsDependent);
16592+
assert(!IsDependent);
16593+
return Result;
1659016594
} else if (Second == nullptr || isPostIncDec) {
1659116595
if (!First->getType()->isOverloadableType() ||
1659216596
(Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {

0 commit comments

Comments
 (0)