Hi, Viktor. Fair question; it's not the most well-documented part of Clang. You 
got the context and the build options right, but the decl is supposed to be the 
function you're creating the CFG for. The statement is indeed the body of the 
function.

(Why do you pass both of them? Well, you can actually omit the decl and pass 
any arbitrary statement, so that you can get a CFG for just part of a program, 
or for the initializer of a global variable, or something like that. A better 
interface would probably be to allow you to pass a statement or a decl, because 
passing any statement other than the decl's immediate body may cause some 
problems.)

Hope that helps,
Jordan

On Mar 24, 2014, at 4:04 , Viktor Kaszian <kasz...@cs.uni-bonn.de> wrote:

> Hi Jordan,
> 
> thanks for your advice. It took me a while to get through the LibTooling. By 
> mostly copying the code from your link, i wrote up a few lines of code. 
> However since i am just setting up for testing, I have not gotten around to 
> test this yet.
> 
> However i have a few questions: buildCFG takes four parameters:
> - a Decl
> - a Stmt
> - an ASTContext
> - buildOptions
> 
> To be honest i am not exactly clear on what is what here.
> 
> I called it like this:
> 
> myCFG = CFG::buildCFG(inFile, getBody(), *Context, cfgBuildOptions);
> 
> which i mostly copied from
> 
> http://clang.llvm.org/doxygen/AnalysisDeclContext_8cpp_source.html#l00179
> 
> I will append my current code. You will notice that i am fairly novice in 
> terms of coding. Please excuse any blatant mistakes.
> 
> Best regards,
> Viktor
> 
> 
> Am 19.03.2014 17:47, schrieb Jordan Rose:
>> 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
>> <http://clang.llvm.org/docs/RAVFrontendAction.html> 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
> <FindCFGFrontendTool.cpp>

_______________________________________________
cfe-users mailing list
cfe-users@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

Reply via email to