Fix -ast-dump of dependent new and delete exprs

llvm-svn: 232748
This commit is contained in:
Reid Kleckner 2015-03-19 18:47:47 +00:00
parent 5196fe7c19
commit 461c0c6934
2 changed files with 22 additions and 8 deletions

View File

@ -1921,24 +1921,28 @@ void ASTDumper::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node) {
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

View File

@ -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'$}}