Clang C interface `clang_visitChildren` problems


I’m using a Clang C interface clang_visitChildren to traverse the abstract syntax tree in Clang. But I get following problems :

  1. Get operators in the expression :
    For expressions like a+b, I can get the current cursor information (name, kind, type) and its child node info, but I don’t know how can I get the operator ‘+’ ? Should I use token to get the operators in expression? If so, please tell me how can I use token to get operators.
  2. Get the value of constants :
    For expressions like int a =10, for the node 10, I can get the result by using clang_Cursor_Evaluate interface, and then call the function clang_EvalResult_getAsInt to get the integer value 10. But, for expressions like int a = 2+8, I got 2+8 and keep traverse down, using the same approach, then I got two 0. Did get the value by a wrong way?What’s the correct way to get the value?
  3. Location order of the child node in the abstract syntax tree :
    If I have two statement for (; ; a) {...} and for (; a; ) {...}, I use clang_visitChildren to traverse them, then I got two subtree: UnexposedExpr and CompoundStmt, How can I separate the two statements? And why did I get UnexposedExpr, what does it means?
    I don’t know how to solve these problems, I hope that someone can help.
    Thank you in advance, Freya