forked from OSchip/llvm-project
Add -ast-dump support for new and delete expressions to help figure out which operator got selected
llvm-svn: 232740
This commit is contained in:
parent
e4f77deaeb
commit
5c682bc4b8
|
@ -508,6 +508,8 @@ namespace {
|
|||
void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node);
|
||||
void VisitCXXConstructExpr(const CXXConstructExpr *Node);
|
||||
void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node);
|
||||
void VisitCXXNewExpr(const CXXNewExpr *Node);
|
||||
void VisitCXXDeleteExpr(const CXXDeleteExpr *Node);
|
||||
void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node);
|
||||
void VisitExprWithCleanups(const ExprWithCleanups *Node);
|
||||
void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);
|
||||
|
@ -1917,6 +1919,28 @@ void ASTDumper::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node) {
|
|||
dumpCXXTemporary(Node->getTemporary());
|
||||
}
|
||||
|
||||
void ASTDumper::VisitCXXNewExpr(const CXXNewExpr *Node) {
|
||||
VisitExpr(Node);
|
||||
OS << ' ';
|
||||
if (Node->isGlobalNew())
|
||||
OS << "global ";
|
||||
if (Node->isArray())
|
||||
OS << "array ";
|
||||
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 ";
|
||||
if (Node->isArrayForm())
|
||||
OS << "array ";
|
||||
dumpBareDeclRef(Node->getOperatorDelete());
|
||||
}
|
||||
|
||||
void
|
||||
ASTDumper::VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node) {
|
||||
VisitExpr(Node);
|
||||
|
|
|
@ -38,3 +38,20 @@ void TestCatch2() {
|
|||
catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestAllocationExprs() {
|
||||
int *p;
|
||||
p = new int;
|
||||
delete p;
|
||||
p = new int[2];
|
||||
delete[] p;
|
||||
p = ::new int;
|
||||
::delete p;
|
||||
}
|
||||
// CHECK: FunctionDecl {{.*}} TestAllocationExprs
|
||||
// CHECK: CXXNewExpr {{.*}} 'int *' Function {{.*}} 'operator new'
|
||||
// CHECK: CXXDeleteExpr {{.*}} 'void' Function {{.*}} 'operator delete'
|
||||
// CHECK: CXXNewExpr {{.*}} 'int *' array Function {{.*}} 'operator new[]'
|
||||
// CHECK: CXXDeleteExpr {{.*}} 'void' array Function {{.*}} 'operator delete[]'
|
||||
// CHECK: CXXNewExpr {{.*}} 'int *' global Function {{.*}} 'operator new'
|
||||
// CHECK: CXXDeleteExpr {{.*}} 'void' global Function {{.*}} 'operator delete'
|
||||
|
|
Loading…
Reference in New Issue