summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorBruno Ricci <riccibrun@gmail.com>2018-12-03 14:54:03 +0000
committerBruno Ricci <riccibrun@gmail.com>2018-12-03 14:54:03 +0000
commit4c9a019d1e22b67d65d0c42f133ccb29a1e3d54b (patch)
tree9e093b5fd9252b0ecba5e94785980620f8a00160 /clang/lib/Sema/SemaOverload.cpp
parent7254d3c51c12ada02b1d75c5bfe22a7fdd87a120 (diff)
downloadbcm5719-llvm-4c9a019d1e22b67d65d0c42f133ccb29a1e3d54b.tar.gz
bcm5719-llvm-4c9a019d1e22b67d65d0c42f133ccb29a1e3d54b.zip
[AST][Sema] Remove CallExpr::setNumArgs
CallExpr::setNumArgs is the only thing that prevents storing the arguments in a trailing array. There is only 3 places in Sema where setNumArgs is called. D54900 dealt with one of them. This patch remove the other two calls to setNumArgs in ConvertArgumentsForCall. To do this we do the following changes: 1.) Replace the first call to setNumArgs by an assertion since we are moving the responsability to allocate enough space for the arguments from Sema::ConvertArgumentsForCall to its callers (which are Sema::BuildCallToMemberFunction, and Sema::BuildResolvedCallExpr). 2.) Add a new member function CallExpr::shrinkNumArgs, which can only be used to drop arguments and then replace the second call to setNumArgs by shrinkNumArgs. 3.) Add a new defaulted parameter MinNumArgs to CallExpr and its derived classes which specifies a minimum number of argument slots to allocate. The actual number of arguments slots allocated will be max(number of args, MinNumArgs) with the extra args nulled. Note that after the creation of the call expression all of the arguments will be non-null. It is just during the creation of the call expression that some of the last arguments can be temporarily null, until filled by default arguments. 4.) Update Sema::BuildCallToMemberFunction by passing the number of parameters in the function prototype to the constructor of CXXMemberCallExpr. Here the change is pretty straightforward. 5.) Update Sema::BuildResolvedCallExpr. Here the change is more complicated since the type-checking for the function type was done after the creation of the call expression. We need to move this before the creation of the call expression, and then pass the number of parameters in the function prototype (if any) to the constructor of the call expression. 6.) Update the deserialization of CallExpr and its derived classes. Differential Revision: https://reviews.llvm.org/D54902 Reviewed By: aaron.ballman llvm-svn: 348145
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index b53c0adda94..614b83d5248 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -12836,7 +12836,8 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
CXXMemberCallExpr *call
= new (Context) CXXMemberCallExpr(Context, MemExprE, Args,
- resultType, valueKind, RParenLoc);
+ resultType, valueKind, RParenLoc,
+ proto->getNumParams());
if (CheckCallReturnType(proto->getReturnType(), op->getRHS()->getBeginLoc(),
call, nullptr))
@@ -12986,9 +12987,11 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
ResultType = ResultType.getNonLValueExprType(Context);
assert(Method && "Member call to something that isn't a method?");
+ const auto *Proto = Method->getType()->getAs<FunctionProtoType>();
CXXMemberCallExpr *TheCall =
new (Context) CXXMemberCallExpr(Context, MemExprE, Args,
- ResultType, VK, RParenLoc);
+ ResultType, VK, RParenLoc,
+ Proto->getNumParams());
// Check for a valid return type.
if (CheckCallReturnType(Method->getReturnType(), MemExpr->getMemberLoc(),
@@ -13008,8 +13011,6 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
}
// Convert the rest of the arguments
- const FunctionProtoType *Proto =
- Method->getType()->getAs<FunctionProtoType>();
if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
RParenLoc))
return ExprError();
OpenPOWER on IntegriCloud