diff options
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 41a342942c8..76fcaeae58d 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1074,21 +1074,24 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // To perform this comparison, we compute the function type that // the deallocation function should have, and use that type both // for template argument deduction and for comparison purposes. + // + // FIXME: this comparison should ignore CC and the like. QualType ExpectedFunctionType; { const FunctionProtoType *Proto = OperatorNew->getType()->getAs<FunctionProtoType>(); + llvm::SmallVector<QualType, 4> ArgTypes; ArgTypes.push_back(Context.VoidPtrTy); for (unsigned I = 1, N = Proto->getNumArgs(); I < N; ++I) ArgTypes.push_back(Proto->getArgType(I)); + FunctionProtoType::ExtProtoInfo EPI; + EPI.Variadic = Proto->isVariadic(); + ExpectedFunctionType = Context.getFunctionType(Context.VoidTy, ArgTypes.data(), - ArgTypes.size(), - Proto->isVariadic(), - 0, false, false, 0, 0, - FunctionType::ExtInfo()); + ArgTypes.size(), EPI); } for (LookupResult::iterator D = FoundDelete.begin(), @@ -1340,12 +1343,15 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, assert(StdBadAlloc && "Must have std::bad_alloc declared"); BadAllocType = Context.getTypeDeclType(getStdBadAlloc()); } + + FunctionProtoType::ExtProtoInfo EPI; + EPI.HasExceptionSpec = true; + if (HasBadAllocExceptionSpec) { + EPI.NumExceptions = 1; + EPI.Exceptions = &BadAllocType; + } - QualType FnType = Context.getFunctionType(Return, &Argument, 1, false, 0, - true, false, - HasBadAllocExceptionSpec? 1 : 0, - &BadAllocType, - FunctionType::ExtInfo()); + QualType FnType = Context.getFunctionType(Return, &Argument, 1, EPI); FunctionDecl *Alloc = FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), Name, FnType, /*TInfo=*/0, SC_None, |