From 255b85f03c5db51478ea80146af5906adfb7c02a Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 8 May 2019 01:36:36 +0000 Subject: [PATCH] Split ActOnCallExpr into an ActOnCallExpr to be called by the parser, and a BuildCallExpr to be called internally within Sema to build / rebuild calls. llvm-svn: 360217 --- clang/include/clang/Sema/Sema.h | 3 +++ clang/lib/Sema/Sema.cpp | 2 +- clang/lib/Sema/SemaCUDA.cpp | 2 +- clang/lib/Sema/SemaChecking.cpp | 2 +- clang/lib/Sema/SemaCoroutine.cpp | 12 ++++++------ clang/lib/Sema/SemaDeclCXX.cpp | 6 +++--- clang/lib/Sema/SemaExpr.cpp | 12 +++++++++--- clang/lib/Sema/SemaOverload.cpp | 8 ++++---- clang/lib/Sema/SemaPseudoObject.cpp | 4 ++-- clang/lib/Sema/TreeTransform.h | 4 ++-- 10 files changed, 32 insertions(+), 23 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 4ab3d0c..0ce3425 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4492,6 +4492,9 @@ public: /// locations. ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, + Expr *ExecConfig = nullptr); + ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, + MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig = nullptr, bool IsExecConfig = false); ExprResult diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 7659d7c..71b2f47 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -2060,7 +2060,7 @@ bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, // FIXME: Try this before emitting the fixit, and suppress diagnostics // while doing so. - E = ActOnCallExpr(nullptr, E.get(), Range.getEnd(), None, + E = BuildCallExpr(nullptr, E.get(), Range.getEnd(), None, Range.getEnd().getLocWithOffset(1)); return true; } diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index d062e8b..203c09c 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -50,7 +50,7 @@ ExprResult Sema::ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, DeclRefExpr(Context, ConfigDecl, false, ConfigQTy, VK_LValue, LLLLoc); MarkFunctionReferenced(LLLLoc, ConfigDecl); - return ActOnCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, nullptr, + return BuildCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc, nullptr, /*IsExecConfig=*/true); } diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index d0479b8..f2aa931 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4885,7 +4885,7 @@ static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex) { /// We have a call to a function like __sync_fetch_and_add, which is an /// overloaded function based on the pointer type of its first argument. -/// The main ActOnCallExpr routines have already promoted the types of +/// The main BuildCallExpr routines have already promoted the types of /// arguments because all of these calls are prototyped as void(...). /// /// This function goes through and does final semantic checking for these diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp index 9d328f4..dc259fe 100644 --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -312,7 +312,7 @@ static Expr *buildBuiltinCall(Sema &S, SourceLocation Loc, Builtin::ID Id, assert(DeclRef.isUsable() && "Builtin reference cannot fail"); ExprResult Call = - S.ActOnCallExpr(/*Scope=*/nullptr, DeclRef.get(), Loc, CallArgs, Loc); + S.BuildCallExpr(/*Scope=*/nullptr, DeclRef.get(), Loc, CallArgs, Loc); assert(!Call.isInvalid() && "Call to builtin cannot fail!"); return Call.get(); @@ -342,7 +342,7 @@ static ExprResult buildCoroutineHandle(Sema &S, QualType PromiseType, if (FromAddr.isInvalid()) return ExprError(); - return S.ActOnCallExpr(nullptr, FromAddr.get(), Loc, FramePtr, Loc); + return S.BuildCallExpr(nullptr, FromAddr.get(), Loc, FramePtr, Loc); } struct ReadySuspendResumeResult { @@ -374,7 +374,7 @@ static ExprResult buildMemberCall(Sema &S, Expr *Base, SourceLocation Loc, return ExprError(); } - return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr); + return S.BuildCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr); } // See if return type is coroutine-handle and if so, invoke builtin coro-resume @@ -1105,7 +1105,7 @@ bool CoroutineStmtBuilder::makeReturnOnAllocFailure() { return false; ExprResult ReturnObjectOnAllocationFailure = - S.ActOnCallExpr(nullptr, DeclNameExpr.get(), Loc, {}, Loc); + S.BuildCallExpr(nullptr, DeclNameExpr.get(), Loc, {}, Loc); if (ReturnObjectOnAllocationFailure.isInvalid()) return false; @@ -1268,7 +1268,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() { NewArgs.push_back(Arg); ExprResult NewExpr = - S.ActOnCallExpr(S.getCurScope(), NewRef.get(), Loc, NewArgs, Loc); + S.BuildCallExpr(S.getCurScope(), NewRef.get(), Loc, NewArgs, Loc); NewExpr = S.ActOnFinishFullExpr(NewExpr.get(), /*DiscardedValue*/ false); if (NewExpr.isInvalid()) return false; @@ -1294,7 +1294,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() { DeleteArgs.push_back(FrameSize); ExprResult DeleteExpr = - S.ActOnCallExpr(S.getCurScope(), DeleteRef.get(), Loc, DeleteArgs, Loc); + S.BuildCallExpr(S.getCurScope(), DeleteRef.get(), Loc, DeleteArgs, Loc); DeleteExpr = S.ActOnFinishFullExpr(DeleteExpr.get(), /*DiscardedValue*/ false); if (DeleteExpr.isInvalid()) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 7e4aab0..a47c404 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1158,7 +1158,7 @@ static bool checkTupleLikeDecomposition(Sema &S, if (E.isInvalid()) return true; - E = S.ActOnCallExpr(nullptr, E.get(), Loc, None, Loc); + E = S.BuildCallExpr(nullptr, E.get(), Loc, None, Loc); } else { // Otherwise, the initializer is get(e), where get is looked up // in the associated namespaces. @@ -1168,7 +1168,7 @@ static bool checkTupleLikeDecomposition(Sema &S, UnresolvedSetIterator(), UnresolvedSetIterator()); Expr *Arg = E.get(); - E = S.ActOnCallExpr(nullptr, Get, Loc, Arg, Loc); + E = S.BuildCallExpr(nullptr, Get, Loc, Arg, Loc); } if (E.isInvalid()) return true; @@ -11562,7 +11562,7 @@ buildMemcpyForAssignmentOp(Sema &S, SourceLocation Loc, QualType T, Expr *CallArgs[] = { To, From, IntegerLiteral::Create(S.Context, Size, SizeType, Loc) }; - ExprResult Call = S.ActOnCallExpr(/*Scope=*/nullptr, MemCpyRef.get(), + ExprResult Call = S.BuildCallExpr(/*Scope=*/nullptr, MemCpyRef.get(), Loc, CallArgs, Loc); assert(!Call.isInvalid() && "Call to __builtin_memcpy cannot fail!"); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index b5e6b62..d8c0896 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -917,7 +917,7 @@ ExprResult Sema::DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, if (TrapFn.isInvalid()) return ExprError(); - ExprResult Call = ActOnCallExpr(TUScope, TrapFn.get(), E->getBeginLoc(), + ExprResult Call = BuildCallExpr(TUScope, TrapFn.get(), E->getBeginLoc(), None, E->getEndLoc()); if (Call.isInvalid()) return ExprError(); @@ -5515,10 +5515,16 @@ tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs( } } -/// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. +ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, + MultiExprArg ArgExprs, SourceLocation RParenLoc, + Expr *ExecConfig) { + return BuildCallExpr(Scope, Fn, LParenLoc, ArgExprs, RParenLoc, ExecConfig); +} + +/// BuildCallExpr - Handle a call to Fn with the specified array of arguments. /// This provides the location of the left/right parens and a list of comma /// locations. -ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, +ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig, bool IsExecConfig) { // Since this might be a postfix expression, get rid of ParenListExprs. diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index df979b6..3fbd635 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -11995,7 +11995,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn, // This shouldn't cause an infinite loop because we're giving it // an expression with viable lookup results, which should never // end up here. - return SemaRef.ActOnCallExpr(/*Scope*/ nullptr, NewFn.get(), LParenLoc, + return SemaRef.BuildCallExpr(/*Scope*/ nullptr, NewFn.get(), LParenLoc, MultiExprArg(Args.data(), Args.size()), RParenLoc); } @@ -13304,7 +13304,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, "Found Decl & conversion-to-functionptr should be same, right?!"); // We selected one of the surrogate functions that converts the // object parameter to a function pointer. Perform the conversion - // on the object argument, then let ActOnCallExpr finish the job. + // on the object argument, then let BuildCallExpr finish the job. // Create an implicit member expr to refer to the conversion operator. // and then call it. @@ -13317,7 +13317,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj, CK_UserDefinedConversion, Call.get(), nullptr, VK_RValue); - return ActOnCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc); + return BuildCallExpr(S, Call.get(), LParenLoc, Args, RParenLoc); } CheckMemberOperatorAccess(LParenLoc, Object.get(), nullptr, Best->FoundDecl); @@ -13656,7 +13656,7 @@ Sema::BuildForRangeBeginEndCall(SourceLocation Loc, *CallExpr = ExprError(); return FRS_DiagnosticIssued; } - *CallExpr = ActOnCallExpr(S, MemberRef.get(), Loc, None, Loc, nullptr); + *CallExpr = BuildCallExpr(S, MemberRef.get(), Loc, None, Loc, nullptr); if (CallExpr->isInvalid()) { *CallExpr = ExprError(); return FRS_DiagnosticIssued; diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp index 28a4d62..06bcd8d 100644 --- a/clang/lib/Sema/SemaPseudoObject.cpp +++ b/clang/lib/Sema/SemaPseudoObject.cpp @@ -1491,7 +1491,7 @@ ExprResult MSPropertyOpBuilder::buildGet() { return ExprError(); } - return S.ActOnCallExpr(S.getCurScope(), GetterExpr.get(), + return S.BuildCallExpr(S.getCurScope(), GetterExpr.get(), RefExpr->getSourceRange().getBegin(), CallArgs, RefExpr->getSourceRange().getEnd()); } @@ -1523,7 +1523,7 @@ ExprResult MSPropertyOpBuilder::buildSet(Expr *op, SourceLocation sl, SmallVector ArgExprs; ArgExprs.append(CallArgs.begin(), CallArgs.end()); ArgExprs.push_back(op); - return S.ActOnCallExpr(S.getCurScope(), SetterExpr.get(), + return S.BuildCallExpr(S.getCurScope(), SetterExpr.get(), RefExpr->getSourceRange().getBegin(), ArgExprs, op->getSourceRange().getEnd()); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index aa5f645..ab2ed25 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -2267,8 +2267,8 @@ public: MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig = nullptr) { - return getSema().ActOnCallExpr(/*Scope=*/nullptr, Callee, LParenLoc, - Args, RParenLoc, ExecConfig); + return getSema().BuildCallExpr(/*Scope=*/nullptr, Callee, LParenLoc, Args, + RParenLoc, ExecConfig); } /// Build a new member access expression. -- 2.7.4