[cfe-commits] r116891 - /cfe/trunk/lib/AST/ExprCXX.cpp
Craig Silverstein
csilvers2000 at yahoo.com
Tue Oct 19 17:38:15 PDT 2010
Author: csilvers
Date: Tue Oct 19 19:38:15 2010
New Revision: 116891
URL: http://llvm.org/viewvc/llvm-project?rev=116891&view=rev
Log:
The type-to-delete may not be a pointer if it's a dependent type.
Here's example code:
---
template<class T> class MyClass {
struct S { };
S* NewS() { return new S; }
void DeleteS() { delete NewS(); }
};
---
CXXDeleteExpr::getDestroyedType() on the 'delete NewS()' expression
would crash before this change. Now it returns a dependent type
object. Solution suggested by dgregor.
Modified:
cfe/trunk/lib/AST/ExprCXX.cpp
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=116891&r1=116890&r2=116891&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Oct 19 19:38:15 2010
@@ -158,8 +158,12 @@
else
break;
}
+ // The type-to-delete may not be a pointer if it's a dependent type.
+ const Type *ArgType = Arg->getType();
+ if (ArgType->isDependentType())
+ return ArgType;
- return Arg->getType()->getAs<PointerType>()->getPointeeType();
+ return ArgType->getAs<PointerType>()->getPointeeType();
}
Stmt::child_iterator CXXDeleteExpr::child_begin() { return &Argument; }
More information about the cfe-commits
mailing list