[cfe-dev] libTooling Questions : EndVisit like functionality

Hemant Bhagat via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 14 23:47:26 PST 2016


Hi,

I have just started experimenting with clang AST and libTooling.
My project requirement is to generate a json from an AST using libTooling.
For that I need to track the end of every visit.

For example.

int main()
{
              Int x = 10;
              return 0;
}


Corresponding json looks like (not the exact format)
{
              TranslationUnit
              {
                             Function <main>
                            {
                                           {
                                                          Return Type <int>
                                           }
                                           {
                                                          End Return Type
                                           }
                                           {
                                                          Block Stmt "{"
                                           }
                                           {
                                                          Variable Declaration x
                                           }
                                           {
                                                          End Variable Declaration
                                           }
                                           {
                                                          Return Stmt 0
                                           }
                                           {
                                                          End Return Stmt
                                           }
                                           {
                                                          End Block Stmt
                                           }
                             }
                             {
                                           End Function
                             }
   }
   {
             End TranslationUnit
   }
}


In the above code, I will create a json node for every token visit recursively from AST. (see example json above)
Question: How will I get the know that the function has reached the end while visiting nodes. (highlighted in bold red)
OR is there any way to control the AST visitors as If we visit the children of function then all the children get visited twice.

Any kind of help is really very appreciated as it is very important.

Thanks,
Hemant
DISCLAIMER :- This e-mail may contain privileged and confidential information which is the property of Acellere GmbH and its associated companies. It is intended only for the use of the individual or entity to whom it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Acellere GmbH and its associated companies does not accept any liability for virus infected mails.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161215/a63b8c8a/attachment.html>


More information about the cfe-dev mailing list