aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCXXExpr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGCXXExpr.cpp')
-rw-r--r--lib/CodeGen/CGCXXExpr.cpp14
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");