[cfe-commits] r88890 - in /cfe/trunk: lib/CodeGen/CGCXXExpr.cpp test/CodeGenCXX/delete-two-arg.cpp
Eli Friedman
eli.friedman at gmail.com
Sun Nov 15 21:16:40 PST 2009
Author: efriedma
Date: Sun Nov 15 23:16:40 2009
New Revision: 88890
URL: http://llvm.org/viewvc/llvm-project?rev=88890&view=rev
Log:
Implement two-argument form of delete operator.
Added:
cfe/trunk/test/CodeGenCXX/delete-two-arg.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXXExpr.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXXExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXExpr.cpp?rev=88890&r1=88889&r2=88890&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXXExpr.cpp Sun Nov 15 23:16:40 2009
@@ -325,6 +325,14 @@
llvm::Value *DeletePtr = Builder.CreateBitCast(Ptr, ConvertType(ArgTy));
DeleteArgs.push_back(std::make_pair(RValue::get(DeletePtr), ArgTy));
+ if (DeleteFTy->getNumArgs() == 2) {
+ QualType SizeTy = DeleteFTy->getArgType(1);
+ uint64_t SizeVal = getContext().getTypeSize(DeleteTy) / 8;
+ llvm::Constant *Size = llvm::ConstantInt::get(ConvertType(SizeTy),
+ SizeVal);
+ DeleteArgs.push_back(std::make_pair(RValue::get(Size), SizeTy));
+ }
+
// Emit the call to delete.
EmitCall(CGM.getTypes().getFunctionInfo(DeleteFTy->getResultType(),
DeleteArgs),
Added: cfe/trunk/test/CodeGenCXX/delete-two-arg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/delete-two-arg.cpp?rev=88890&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/delete-two-arg.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/delete-two-arg.cpp Sun Nov 15 23:16:40 2009
@@ -0,0 +1,6 @@
+// RUN: clang-cc %s -o - -emit-llvm -verify | FileCheck %s
+
+struct A { void operator delete(void*,__typeof(sizeof(int))); int x; };
+void a(A* x) { delete x; }
+
+// CHECK: call void @_ZN1AdlEPvj(i8* %0, i32 4)
More information about the cfe-commits
mailing list