[cfe-users] Using Clang for CFG creation

Jordan Rose jordan_rose at apple.com
Wed Mar 19 09:47:21 PDT 2014


Both DumpCFG and ViewCFG are meant as debug tools for working on the Clang static analyzer; in particular, the way the CFG is built for the analyzer may not match your needs.

If you are willing to write your own tool based on Clang's C++ interface, you can get a parsed AST and then ask for the CFG of any particular function using CFG::buildCFG. Note, though that the C++ API is not stable from release to release.

Jordan


On Mar 19, 2014, at 6:28 , Hugues de Lassus <hugues.de-lassus at imag.fr> wrote:

> Hi,
> 
> I was looking for exactly the same kind of tool. :)
> You may be interested by
> clang -cc1 -analyze -analyzer-checker=debug.ViewCFG test.cpp
> 
> It generates a ps file in /tmp/ from a dot file which I cannot reach at the moment.
> 
> Cheers,
> 
> On 03/19/2014 09:00 AM, Viktor Kaszian wrote:
>> Hi everyone!
>> 
>> I'm currently working on a project for which i need a way to parse
>> c/c++ source code and convert it into a CFG.
>> 
>> I happened upon Clang just a few days ago, and have been trying to
>> figure out how to use it to create my CFG, but i failed. All i can use
>> Clang for at the moment is using
>> 
>> clang -cc1 -analyze -analyzer-checker=debug.DumpCFG test.cpp
>> 
>> But this only yields a textual representation. Worst case i could
>> write a parser for the output. I would much prefer to find a way to
>> extract the CFG as it is used within Clang to my application.
>> 
>> The best would be if i could just call a function in Clang from my
>> application and get the CFG returned.
>> 
>> Thanks for your time and answers. It is much appreciated.
>> Viktor
>> _______________________________________________
>> cfe-users mailing list
>> cfe-users at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
> 
> 
> -- 
> 
> Hugues de Lassus Saint-Geni├Ęs
> 
> _______________________________________________
> cfe-users mailing list
> cfe-users at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140319/c590fc49/attachment.html>


More information about the cfe-users mailing list