This is some Program fragments for test:
bool conver(int a,int b)
Now my problem is that I traverse them by some code as follows,i can't get
the defined size of array a and b.the reason is obvious,the section 1 is
traversed before section 2.I wonder someone can give me a better method to
break this trouble,thank you!
bool MyASTConsumer::HandleTopLevelDecl(DeclGroupRef d)
typedef DeclGroupRef::iterator iter;
for (iter b = d.begin(), e = d.end(); b != e; ++b)
return true; // keep going
I am also looking to get defined size of array.
Using VisitDeclStmt(Stmt *s), I can get following info:
decl statement: int dummy
identifier name = dummy
type = int 
But how to get defined size?
Also using, VisitBinAssign(BinaryOperator *E) and
VisitArraySubscriptExpr(ArraySubscriptExpr* S), I can get following info:
Assignment Op = in B1
RHS value: 10
found array subscript expr
identifier = arr
index value: 9
But why I am getting RHS first for arr = 10;? I should get first LHS
arr and then RHS value 10, since Visit methods are called in pre-order
DFS manner as AST is traverse. Correct me if it is otherwise?
I am having same trouble when I have unary minus on LHS of a binary
operation (e.g. x = -1 + x;), then VisitUnaryMinus() is getting visited
after RHS? why it is so?