Treat nothrow forms of ::operator delete and ::operator delete[] as

deallocation functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186798 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Richard Smith
2013-07-21 23:11:42 +00:00
parent 02a1364bf8
commit 72c8331ec1
4 changed files with 40 additions and 4 deletions

View File

@@ -318,9 +318,15 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
if (!TLI || !TLI->getLibFunc(FnName, TLIFn) || !TLI->has(TLIFn))
return 0;
if (TLIFn != LibFunc::free &&
TLIFn != LibFunc::ZdlPv && // operator delete(void*)
TLIFn != LibFunc::ZdaPv) // operator delete[](void*)
unsigned ExpectedNumParams;
if (TLIFn == LibFunc::free ||
TLIFn == LibFunc::ZdlPv || // operator delete(void*)
TLIFn == LibFunc::ZdaPv) // operator delete[](void*)
ExpectedNumParams = 1;
else if (TLIFn == LibFunc::ZdlPvRKSt9nothrow_t || // delete(void*, nothrow)
TLIFn == LibFunc::ZdaPvRKSt9nothrow_t) // delete[](void*, nothrow)
ExpectedNumParams = 2;
else
return 0;
// Check free prototype.
@@ -329,7 +335,7 @@ const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
FunctionType *FTy = Callee->getFunctionType();
if (!FTy->getReturnType()->isVoidTy())
return 0;
if (FTy->getNumParams() != 1)
if (FTy->getNumParams() != ExpectedNumParams)
return 0;
if (FTy->getParamType(0) != Type::getInt8PtrTy(Callee->getContext()))
return 0;