Kaydet (Commit) 9d65113e authored tarafından Luboš Luňák's avatar Luboš Luňák

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
üst 67db35da
...@@ -100,11 +100,23 @@ bool ParentBuilder::VisitFunctionDecl( const FunctionDecl* function ) ...@@ -100,11 +100,23 @@ bool ParentBuilder::VisitFunctionDecl( const FunctionDecl* function )
{ {
// if( ignoreLocation( declaration )) // if( ignoreLocation( declaration ))
// return true; ??? // return true; ???
if( !function->doesThisDeclarationHaveABody()) if( function->doesThisDeclarationHaveABody())
return true; {
const Stmt* body = function->getBody(); const Stmt* body = function->getBody();
(*parents)[ body ] = NULL; // no parent (*parents)[ body ] = NULL; // no parent
walk( body ); 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; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment