diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-29 18:16:17 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-29 18:16:17 +0000 |
commit | 9091656e423f2354e53b2b3baa95b3eb5510badc (patch) | |
tree | f14e46bc7e2fe2460d0bd86c585d467aeddd6f66 /lib/CodeGen/CGCXXExpr.cpp | |
parent | 4a6a2b80c1771a2688a6349f8302263a3ebf4659 (diff) |
Handle C++ delete expressions when the overloaded delete operator is a
"usual deallocation function" with two arguments. CodeGen will have to
handle this case specifically, since the value for the second argument
(the size of the allocated object) may have to be computed at run
time.
Fixes the Sema part of PR4782.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83080 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXXExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGCXXExpr.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/CodeGen/CGCXXExpr.cpp b/lib/CodeGen/CGCXXExpr.cpp index 1ee4ceb136..7dd6427752 100644 --- a/lib/CodeGen/CGCXXExpr.cpp +++ b/lib/CodeGen/CGCXXExpr.cpp @@ -239,10 +239,18 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { return; }; - QualType DeleteTy = - E->getArgument()->getType()->getAs<PointerType>()->getPointeeType(); + // Get at the argument before we performed the implicit conversion + // to void*. + const Expr *Arg = E->getArgument(); + while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) { + if (ICE->getCastKind() != CastExpr::CK_UserDefinedConversion && + ICE->getType()->isVoidPointerType()) + Arg = ICE->getSubExpr(); + } + + QualType DeleteTy = Arg->getType()->getAs<PointerType>()->getPointeeType(); - llvm::Value *Ptr = EmitScalarExpr(E->getArgument()); + llvm::Value *Ptr = EmitScalarExpr(Arg); // Null check the pointer. llvm::BasicBlock *DeleteNotNull = createBasicBlock("delete.notnull"); |