diff options
| author | Craig Silverstein <csilvers2000@yahoo.com> | 2010-11-16 07:16:25 +0000 |
|---|---|---|
| committer | Craig Silverstein <csilvers2000@yahoo.com> | 2010-11-16 07:16:25 +0000 |
| commit | 9e448da3240813be12b9546cd60e5e755a52dd97 (patch) | |
| tree | b83547dc9fd9a316bfc9e16b074e4f9db7bcb943 | |
| parent | 4098598ca88c61d8c6123cd0f42e03ba57eb7f9f (diff) | |
| download | bcm5719-llvm-9e448da3240813be12b9546cd60e5e755a52dd97.tar.gz bcm5719-llvm-9e448da3240813be12b9546cd60e5e755a52dd97.zip | |
Have CXXDeleteExpr::getDestroyedType return the actual destroyed type
in more situations. In particular, for code like
template<class T> void Fn() { T* x; delete x; }
getDestroyedType() will now return T rather than T*, as it would
before this change. On the other hand, for code like this:
template<class T> void Fn() { T x; delete x; }
getDestroyedType() will return an empty QualType(), since it doesn't
know what the actual destroyed type would be. Previously, it would
return T.
OKed by rjmccall
llvm-svn: 119334
| -rw-r--r-- | clang/include/clang/AST/ExprCXX.h | 3 | ||||
| -rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 3b8ecf29307..78edd4beecc 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -1150,6 +1150,9 @@ public: Expr *getArgument() { return cast<Expr>(Argument); } const Expr *getArgument() const { return cast<Expr>(Argument); } + /// \brief Retrieve the type being destroyed. If the type being + /// destroyed is a dependent type which may or may not be a pointer, + /// return an invalid type. QualType getDestroyedType() const; virtual SourceRange getSourceRange() const { diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 60785d471ac..1820ff77074 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -162,8 +162,9 @@ QualType CXXDeleteExpr::getDestroyedType() const { } // The type-to-delete may not be a pointer if it's a dependent type. const QualType ArgType = Arg->getType(); - if (ArgType->isDependentType()) - return ArgType; + + if (ArgType->isDependentType() && !ArgType->isPointerType()) + return QualType(); return ArgType->getAs<PointerType>()->getPointeeType(); } |

