[cfe-dev] how to see implicit calls in AST
Vladimir Voskresensky
voskresensky.vladimir at gmail.com
Sun Sep 15 23:08:38 PDT 2013
Hello,
Any hints how to visit implicit destructor calls by RecursiveASTVisitor?
As a check I used clang-check tool and tried to see destructor calls for
state1 in function "check"
==========/var/tmp/tmp/file.cpp========
class TestModeRAII {
bool &Ref;
bool OldState;
public:
explicit TestModeRAII(bool& State):Ref(State), OldState(State) {}
~TestModeRAII() { Ref = OldState; }
static void check(bool &state) {
if (state) {
TestModeRAII state1(state);
state = false;
}
}
};
================
$ ./clang-check -ast-dump -ast-dump-filter=TestModeRAII::check
/var/tmp/tmp/file.cpp --
Dumping TestModeRAII::check:
CXXMethodDecl 0x23021a0 </var/tmp/tmp/file.cpp:10:3, line:15:3> check
'void (_Bool &)' static
|-ParmVarDecl 0x2302120 <line:10:21, col:27> state '_Bool &'
`-CompoundStmt 0x23028a0 <col:34, line:15:3>
`-IfStmt 0x2302870 <line:11:5, line:14:5>
|-<<<NULL>>>
|-ImplicitCastExpr 0x23024d8 <line:11:9> '_Bool' <LValueToRValue>
| `-DeclRefExpr 0x23024b0 <col:9> '_Bool' lvalue ParmVar 0x2302120
'state' '_Bool &'
|-CompoundStmt 0x2302848 <col:16, line:14:5>
| |-DeclStmt 0x23027c8 <line:12:7, col:33>
| | `-VarDecl 0x2302530 <col:7, col:32> state1 'class TestModeRAII'
| | `-CXXConstructExpr 0x2302790 <col:20, col:32> 'class
TestModeRAII' 'void (_Bool &)'
| | `-DeclRefExpr 0x23024f0 <col:27> '_Bool' lvalue ParmVar
0x2302120 'state' '_Bool &'
| `-BinaryOperator 0x2302820 <line:13:7, col:15> '_Bool' lvalue '='
| |-DeclRefExpr 0x23027e0 <col:7> '_Bool' lvalue ParmVar
0x2302120 'state' '_Bool &'
| `-CXXBoolLiteralExpr 0x2302808 <col:15> '_Bool' false
`-<<<NULL>>>
===================
It doesn't dump destructor calls.
I changed ASTPrinter and added:
bool shouldVisitImplicitCode() const { return true; }
But it still doesn't help.
Thanks,
Vladimir.
More information about the cfe-dev
mailing list