From ed09bfcf04b7470b1c6fca54477f6d3bfcfb3b64 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 00:11:18 +0000 Subject: [PATCH] Revert my r181563, breaks tests on buildbots git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181568 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 4 ++-- lib/Sema/SemaExprCXX.cpp | 39 +++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 8e466385b4..fbc8283121 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -3984,8 +3984,8 @@ public: FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete); bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, - DeclarationName Name, MultiExprArg Args, - DeclContext *Ctx, + DeclarationName Name, Expr** Args, + unsigned NumArgs, DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose = true); void DeclareGlobalNewDelete(); diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 7aaa4a249f..ffe8649637 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1561,16 +1561,18 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, if (AllocElemType->isRecordType() && !UseGlobal) { CXXRecordDecl *Record = cast(AllocElemType->getAs()->getDecl()); - if (FindAllocationOverload(StartLoc, Range, NewName, AllocArgs, Record, - /*AllowMissing=*/true, OperatorNew)) + if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], + AllocArgs.size(), Record, /*AllowMissing=*/true, + OperatorNew)) return true; } if (!OperatorNew) { // Didn't find a member overload. Look for a global one. DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); - if (FindAllocationOverload(StartLoc, Range, NewName, AllocArgs, TUDecl, - /*AllowMissing=*/false, OperatorNew)) + if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], + AllocArgs.size(), TUDecl, /*AllowMissing=*/false, + OperatorNew)) return true; } @@ -1712,8 +1714,8 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, /// FindAllocationOverload - Find an fitting overload for the allocation /// function in the specified scope. bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, - DeclarationName Name, MultiExprArg Args, - DeclContext *Ctx, + DeclarationName Name, Expr** Args, + unsigned NumArgs, DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose) { LookupResult R(*this, Name, StartLoc, LookupOrdinaryName); @@ -1740,13 +1742,15 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (FunctionTemplateDecl *FnTemplate = dyn_cast(D)) { AddTemplateOverloadCandidate(FnTemplate, Alloc.getPair(), /*ExplicitTemplateArgs=*/0, - Args, Candidates, + llvm::makeArrayRef(Args, NumArgs), + Candidates, /*SuppressUserConversions=*/false); continue; } FunctionDecl *Fn = cast(D); - AddOverloadCandidate(Fn, Alloc.getPair(), Args, Candidates, + AddOverloadCandidate(Fn, Alloc.getPair(), + llvm::makeArrayRef(Args, NumArgs), Candidates, /*SuppressUserConversions=*/false); } @@ -1762,7 +1766,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, // asserted on, though, since invalid decls are left in there.) // Watch out for variadic allocator function. unsigned NumArgsInFnDecl = FnDecl->getNumParams(); - for (unsigned i = 0; (i < Args.size() && i < NumArgsInFnDecl); ++i) { + for (unsigned i = 0; (i < NumArgs && i < NumArgsInFnDecl); ++i) { InitializedEntity Entity = InitializedEntity::InitializeParameter(Context, FnDecl->getParamDecl(i)); @@ -1790,7 +1794,8 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (Diagnose) { Diag(StartLoc, diag::err_ovl_no_viable_function_in_call) << Name << Range; - Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); + Candidates.NoteCandidates(*this, OCD_AllCandidates, + llvm::makeArrayRef(Args, NumArgs)); } return true; @@ -1798,7 +1803,8 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, if (Diagnose) { Diag(StartLoc, diag::err_ovl_ambiguous_call) << Name << Range; - Candidates.NoteCandidates(*this, OCD_ViableCandidates, Args); + Candidates.NoteCandidates(*this, OCD_ViableCandidates, + llvm::makeArrayRef(Args, NumArgs)); } return true; @@ -1809,7 +1815,8 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, << Name << getDeletedOrUnavailableSuffix(Best->Function) << Range; - Candidates.NoteCandidates(*this, OCD_AllCandidates, Args); + Candidates.NoteCandidates(*this, OCD_AllCandidates, + llvm::makeArrayRef(Args, NumArgs)); } return true; } @@ -2044,9 +2051,10 @@ bool Sema::FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclContext *TUDecl = Context.getTranslationUnitDecl(); CXXNullPtrLiteralExpr Null(Context.VoidPtrTy, SourceLocation()); - Expr *DeallocArgs[1] = { &Null }; + Expr* DeallocArgs[1]; + DeallocArgs[0] = &Null; if (FindAllocationOverload(StartLoc, SourceRange(), Name, - DeallocArgs, TUDecl, !Diagnose, + DeallocArgs, 1, TUDecl, !Diagnose, Operator, Diagnose)) return true; @@ -2236,12 +2244,11 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); Expr *Arg = Ex.get(); - Expr *DeallocArgs[1] = { Arg }; if (!Context.hasSameType(Arg->getType(), Context.VoidPtrTy)) Arg = ImplicitCastExpr::Create(Context, Context.VoidPtrTy, CK_BitCast, Arg, 0, VK_RValue); if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName, - DeallocArgs, TUDecl, /*AllowMissing=*/false, + &Arg, 1, TUDecl, /*AllowMissing=*/false, OperatorDelete)) return ExprError(); } -- 2.40.0