summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-29 18:16:17 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-29 18:16:17 +0000
commitbb3e12fc0bd07b7032b9c42e457e622d9635c455 (patch)
treec6a910da4908d1c5a5b5e03c1226b72c9287b7a6 /clang/lib/CodeGen
parent91ae9fd9e8e03be82928a1ae312d6848aca09b2f (diff)
downloadbcm5719-llvm-bb3e12fc0bd07b7032b9c42e457e622d9635c455.tar.gz
bcm5719-llvm-bb3e12fc0bd07b7032b9c42e457e622d9635c455.zip
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. llvm-svn: 83080
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGCXXExpr.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGCXXExpr.cpp b/clang/lib/CodeGen/CGCXXExpr.cpp
index 1ee4ceb1369..7dd6427752a 100644
--- a/clang/lib/CodeGen/CGCXXExpr.cpp
+++ b/clang/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");
OpenPOWER on IntegriCloud