diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-05-13 19:56:21 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-05-13 19:56:21 +0000 |
commit | d6f9e73527fb48ade3580f45e03c4590defbf109 (patch) | |
tree | 1fe42912290b0562521f8997d58a7da2e41c8f9a /clang/lib/Sema/SemaExpr.cpp | |
parent | addf51ddde4f06a471b3c40ef8300d6c88919185 (diff) | |
download | bcm5719-llvm-d6f9e73527fb48ade3580f45e03c4590defbf109.tar.gz bcm5719-llvm-d6f9e73527fb48ade3580f45e03c4590defbf109.zip |
PR19729: Delete a bunch of bogus code in Sema::FindAllocationOverload. This
caused us to perform copy-initialization for the parameters of an allocation
function called by a new-expression multiple times, resulting in us rejecting
allocations that passed non-copyable parameters (and much worse things in
MSVC compat mode, where we potentially called this function multiple times).
llvm-svn: 208724
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 3d90f0a655c..33eea164a12 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4164,18 +4164,14 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, VariadicCallType CallType, bool AllowExplicit, bool IsListInitialization) { unsigned NumParams = Proto->getNumParams(); - unsigned NumArgsToCheck = Args.size(); bool Invalid = false; - if (Args.size() != NumParams) - // Use default arguments for missing arguments - NumArgsToCheck = NumParams; unsigned ArgIx = 0; // Continue to check argument types (even if we have too few/many args). - for (unsigned i = FirstParam; i != NumArgsToCheck; i++) { + for (unsigned i = FirstParam; i < NumParams; i++) { QualType ProtoArgType = Proto->getParamType(i); Expr *Arg; - ParmVarDecl *Param; + ParmVarDecl *Param = FDecl ? FDecl->getParamDecl(i) : nullptr; if (ArgIx < Args.size()) { Arg = Args[ArgIx++]; @@ -4184,11 +4180,6 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, diag::err_call_incomplete_argument, Arg)) return true; - // Pass the argument - Param = 0; - if (FDecl && i < FDecl->getNumParams()) - Param = FDecl->getParamDecl(i); - // Strip the unbridged-cast placeholder expression off, if applicable. bool CFAudited = false; if (Arg->getType() == Context.ARCUnbridgedCastTy && @@ -4209,7 +4200,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, // Remember that parameter belongs to a CF audited API. if (CFAudited) Entity.setParameterCFAudited(); - + ExprResult ArgE = PerformCopyInitialization(Entity, SourceLocation(), Owned(Arg), @@ -4220,8 +4211,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, Arg = ArgE.takeAs<Expr>(); } else { - assert(FDecl && "can't use default arguments without a known callee"); - Param = FDecl->getParamDecl(i); + assert(Param && "can't use default arguments without a known callee"); ExprResult ArgExpr = BuildCXXDefaultArgExpr(CallLoc, FDecl, Param); |