diff options
| author | Abramo Bagnara <abramo.bagnara@gmail.com> | 2012-07-09 21:15:43 +0000 |
|---|---|---|
| committer | Abramo Bagnara <abramo.bagnara@gmail.com> | 2012-07-09 21:15:43 +0000 |
| commit | cb43567374aaede26703d1459884901567826594 (patch) | |
| tree | 66da63b1df2bbf5d96edd4587a7c085ce1ade89e /clang/lib | |
| parent | aeed158f75f8ea9e812e49e6c19083c3d409ea03 (diff) | |
| download | bcm5719-llvm-cb43567374aaede26703d1459884901567826594.tar.gz bcm5719-llvm-cb43567374aaede26703d1459884901567826594.zip | |
The delete argument should not be converted to void*.
llvm-svn: 159961
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 11 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 6 |
3 files changed, 3 insertions, 21 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index a7240e6978a..73347b2e01d 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -127,13 +127,6 @@ SourceLocation CXXNewExpr::getEndLoc() const { // CXXDeleteExpr QualType CXXDeleteExpr::getDestroyedType() const { const Expr *Arg = getArgument(); - while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Arg)) { - if (ICE->getCastKind() != CK_UserDefinedConversion && - ICE->getType()->isVoidPointerType()) - Arg = ICE->getSubExpr(); - else - break; - } // The type-to-delete may not be a pointer if it's a dependent type. const QualType ArgType = Arg->getType(); diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index d9dd7764103..79ebe515b0e 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -1533,18 +1533,7 @@ static void EmitArrayDelete(CodeGenFunction &CGF, } void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { - - // 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() != CK_UserDefinedConversion && - ICE->getType()->isVoidPointerType()) - Arg = ICE->getSubExpr(); - else - break; - } - llvm::Value *Ptr = EmitScalarExpr(Arg); // Null check the pointer. diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 9657661a037..ec4bf8221f9 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2148,9 +2148,6 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // delete-expression; it is not necessary to cast away the constness // (5.2.11) of the pointer expression before it is used as the operand // of the delete-expression. ] - if (!Context.hasSameType(Ex.get()->getType(), Context.VoidPtrTy)) - Ex = Owned(ImplicitCastExpr::Create(Context, Context.VoidPtrTy, - CK_BitCast, Ex.take(), 0, VK_RValue)); if (Pointee->isArrayType() && !ArrayForm) { Diag(StartLoc, diag::warn_delete_array_type) @@ -2228,6 +2225,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, DeclareGlobalNewDelete(); DeclContext *TUDecl = Context.getTranslationUnitDecl(); Expr *Arg = Ex.get(); + if (!Context.hasSameType(Arg->getType(), Context.VoidPtrTy)) + Arg = ImplicitCastExpr::Create(Context, Context.VoidPtrTy, + CK_BitCast, Arg, 0, VK_RValue); if (FindAllocationOverload(StartLoc, SourceRange(), DeleteName, &Arg, 1, TUDecl, /*AllowMissing=*/false, OperatorDelete)) |

