diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2013-07-15 19:55:41 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-07-15 23:12:12 +0200 |
commit | 9d65113efeff9b82acddf531d341ecb0e56447a9 (patch) | |
tree | 55003dc57e7656a14438ef65a13ba63210c56cc9 /compilerplugins | |
parent | 67db35da5d7a3b117a0e0035c17c2fb58e5f23e6 (diff) |
fix finding all parents for AST nodes
Ctor bodies can also have code inside of member variables initialization,
which is not considered to be inside function body.
Change-Id: Id68960093a51396b9486f1364b1a361526c3431d
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/plugin.cxx | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index 6611606d793f..7454144f7dfd 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -100,11 +100,23 @@ bool ParentBuilder::VisitFunctionDecl( const FunctionDecl* function ) { // if( ignoreLocation( declaration )) // return true; ??? - if( !function->doesThisDeclarationHaveABody()) - return true; - const Stmt* body = function->getBody(); - (*parents)[ body ] = NULL; // no parent - walk( body ); + if( function->doesThisDeclarationHaveABody()) + { + const Stmt* body = function->getBody(); + (*parents)[ body ] = NULL; // no parent + walk( body ); + } + if( const CXXConstructorDecl* ctor = dyn_cast< CXXConstructorDecl >( function )) + { + for( CXXConstructorDecl::init_const_iterator it = ctor->init_begin(); + it != ctor->init_end(); + ++it ) + { + const Expr* init_expression = (*it)->getInit(); + (*parents)[ init_expression ] = NULL; + walk( init_expression ); + } + } return true; } |