<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>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.</div><div><br></div><div>(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 <i>part</i> 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 <i>or</i> a decl, because passing any statement other than the decl's immediate body may cause some problems.)</div><div><br></div><div>Hope that helps,</div><div>Jordan</div><br><div><div>On Mar 24, 2014, at 4:04 , Viktor Kaszian <<a href="mailto:kaszian@cs.uni-bonn.de">kaszian@cs.uni-bonn.de</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Jordan,<br><br>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.<br><br>However i have a few questions: buildCFG takes four parameters:<br>- a Decl<br>- a Stmt<br>- an ASTContext<br>- buildOptions<br><br>To be honest i am not exactly clear on what is what here.<br><br>I called it like this:<br><br>myCFG = CFG::buildCFG(inFile, getBody(), *Context, cfgBuildOptions);<br><br>which i mostly copied from<br><br><a href="http://clang.llvm.org/doxygen/AnalysisDeclContext_8cpp_source.html#l00179">http://clang.llvm.org/doxygen/AnalysisDeclContext_8cpp_source.html#l00179</a><br><br>I will append my current code. You will notice that i am fairly novice in terms of coding. Please excuse any blatant mistakes.<br><br>Best regards,<br>Viktor<br><br><br>Am 19.03.2014 17:47, schrieb Jordan Rose:<br><blockquote type="cite">Both DumpCFG and ViewCFG are meant as debug tools for working on the<br>Clang static analyzer; in particular, the way the CFG is built for the<br>analyzer may not match your needs.<br><br>If you are willing to write your own tool based on Clang's C++<br>interface, you can get a parsed AST<br><http://clang.llvm.org/docs/RAVFrontendAction.html> and then ask for the<br>CFG of any particular function using CFG::buildCFG. Note, though that<br>the C++ API is not stable from release to release.<br><br>Jordan<br></blockquote><span><FindCFGFrontendTool.cpp></span></blockquote></div><br></body></html>