[cfe-dev] help: from Stmt object to Decl

彩云追月 wuming_81 at 163.com
Tue Jan 27 14:53:36 PST 2015


    Hello, everyone.
    I'm writing a checker for clang static analyzer.My test program is as follows:
int f()
{
struct list l;
if (l.size() == 0)
{
//printf("equals zero\n");
}
}


its ast nodes is :
`-FunctionDecl 0x3b4bad0 <line:25:1, line:32:1> f 'int (void)'
  `-CompoundStmt 0x3b4bf48 <line:26:1, line:32:1>
    |-DeclStmt 0x3b4be20 <line:27:2, col:15>
    | `-VarDecl 0x3b4bbc0 <col:2, col:14> l 'struct list':'struct <anonymous>::list'
    |   `-CXXConstructExpr 0x3b4bdf0 <col:14> 'struct list':'struct <anonymous>::list' 'void (void)'
    `-IfStmt 0x3b4bf18 <line:28:2, line:31:2>
      |-<<<NULL>>>
      |-BinaryOperator 0x3b4bed8 <line:28:6, col:18> '_Bool' '=='
      | |-CXXMemberCallExpr 0x3b4be90 <col:6, col:13> 'int'
      | | `-MemberExpr 0x3b4be60 <col:6, col:8> '<bound member function type>' .size 0x3b4b930
      | |   `-DeclRefExpr 0x3b4be38 <col:6> 'struct list':'struct <anonymous>::list' lvalue Var 0x3b4bbc0 'l' 'struct list':'struct <anonymous>::list'
      | `-IntegerLiteral 0x3b4beb8 <col:18> 'int' 0
      |-CompoundStmt 0x3b4bf00 <line:29:2, line:31:2>
      `-<<<NULL>>>


now I have got the BinaryOperator object, but how could I get the Decl object that represents the function f ?
i.e how could I get the FunctionDecl object ?


Thanks for any suggestion.
                    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150128/3134f301/attachment.html>


More information about the cfe-dev mailing list