r232748 - Fix -ast-dump of dependent new and delete exprs
Reid Kleckner
reid at kleckner.net
Thu Mar 19 11:47:47 PDT 2015
Author: rnk
Date: Thu Mar 19 13:47:47 2015
New Revision: 232748
URL: http://llvm.org/viewvc/llvm-project?rev=232748&view=rev
Log:
Fix -ast-dump of dependent new and delete exprs
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/test/Misc/ast-dump-stmt.cpp
Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=232748&r1=232747&r2=232748&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Thu Mar 19 13:47:47 2015
@@ -1921,24 +1921,28 @@ void ASTDumper::VisitCXXBindTemporaryExp
void ASTDumper::VisitCXXNewExpr(const CXXNewExpr *Node) {
VisitExpr(Node);
- OS << ' ';
if (Node->isGlobalNew())
- OS << "global ";
+ OS << " global";
if (Node->isArray())
- OS << "array ";
- dumpBareDeclRef(Node->getOperatorNew());
+ OS << " array";
+ if (Node->getOperatorNew()) {
+ OS << ' ';
+ dumpBareDeclRef(Node->getOperatorNew());
+ }
// We could dump the deallocation function used in case of error, but it's
// usually not that interesting.
}
void ASTDumper::VisitCXXDeleteExpr(const CXXDeleteExpr *Node) {
VisitExpr(Node);
- OS << ' ';
if (Node->isGlobalDelete())
- OS << "global ";
+ OS << " global";
if (Node->isArrayForm())
- OS << "array ";
- dumpBareDeclRef(Node->getOperatorDelete());
+ OS << " array";
+ if (Node->getOperatorDelete()) {
+ OS << ' ';
+ dumpBareDeclRef(Node->getOperatorDelete());
+ }
}
void
Modified: cfe/trunk/test/Misc/ast-dump-stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-stmt.cpp?rev=232748&r1=232747&r2=232748&view=diff
==============================================================================
--- cfe/trunk/test/Misc/ast-dump-stmt.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-stmt.cpp Thu Mar 19 13:47:47 2015
@@ -55,3 +55,13 @@ void TestAllocationExprs() {
// CHECK: CXXDeleteExpr {{.*}} 'void' array Function {{.*}} 'operator delete[]'
// CHECK: CXXNewExpr {{.*}} 'int *' global Function {{.*}} 'operator new'
// CHECK: CXXDeleteExpr {{.*}} 'void' global Function {{.*}} 'operator delete'
+
+// Don't crash on dependent exprs that haven't been resolved yet.
+template <typename T>
+void TestDependentAllocationExpr() {
+ T *p = new T;
+ delete p;
+}
+// CHECK: FunctionTemplateDecl {{.*}} TestDependentAllocationExpr
+// CHECK: CXXNewExpr {{.*'T \*'$}}
+// CHECK: CXXDeleteExpr {{.*'void'$}}
More information about the cfe-commits
mailing list