[cfe-dev] CFG documentation

Ted Kremenek kremenek at apple.com
Fri Dec 17 08:33:40 PST 2010


On Dec 17, 2010, at 5:40 AM, Gaurav Mittal wrote:

> Hi Ted,
> 
> Thanks for the link. I had actually already gone through all the documentation online and am currently sifting through the source code starting at cfg.h and branching out. I think using the command line to dump the CFG will help get a jump start, thanks.
> 
> Through my posting on the mailing list I was looking for more information on:
> 
> 1. Whether there exists a CFG API that hides the implementation details.
> 
The public methods of the CFG class should be considered as part of its API.

> 2. The CFG structure and how it relates/uses the AST. E.g. how would one lookup the nature of a variable in an expression or its scope, how the symbol tables are accessed, etc. I think this would relate to how the AST gets translated to the CFG.
> 
> 

I think some of your questions more have to do with how some fundamental concepts are represented in Clang in general.  The CFG simply models a control-flow relation between elements (i.e., statements and expressions) in the AST, no more and no less.  It does not encapsulate scope or reason about anything else except statements and expressions.

The AST encapsulates statements, expressions, and declarations.  There is no symbol table per se in the Clang frontend, as all symbols are uniquely identified by their (canonical) declarations.  The LLVM backend reasons about symbols differently since that represents a strictly low-level representation of the program.  Scope is currently not modeled explicitly in the AST, but it can be inferred.  The parser and semantic analyzer reason about scope while building the AST, but that information is not recorded in the AST.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101217/2c1fe264/attachment.html>


More information about the cfe-dev mailing list