[cfe-dev] Data flow analysis in Clang

Ted Kremenek kremenek at apple.com
Fri Nov 14 09:58:05 PST 2014


There's already an analysis, LiveVariables.cpp, that does this.  It works on top of the CFG, and does a reverse dataflow analysis (using a worklist algorithm) to compute liveness information for variables.  This liveness information is currently consumed by the static analyzer to prune out redundant information from the path state.

> On Nov 14, 2014, at 9:21 AM, Madhur Amilkanthwar <madhur13490 at gmail.com> wrote:
> 
> So assume that I want to find all live variables at the end of the block. Then how easy it is to do the job?
> 
> On Nov 14, 2014 2:25 PM, "Manuel Klimek" <klimek at google.com <mailto:klimek at google.com>> wrote:
> You basically have the static analyzer's CFG and Clang's AST. With the AST you can do limited data flow analysis (as long as you don't need path or control flow sensitivity), with the CFG you can do anything you want (at least in C) given enough computing power :P
> 
> AST access is well-integrated in libtooling, CFG access less so (I haven't written a tool that uses the CFG, but given that the CFG is used for Clang's diagnostics, I'd imagine it's not too hard to use from a libTooling based tool).
> 
> Looping in Anna & Jordan for more info on what's possible with the CFG / static analyzer.
> 
> Cheers,
> /Manuel
> 
> On Fri Nov 14 2014 at 6:56:10 AM Vanush Vaswani <vanush at gmail.com <mailto:vanush at gmail.com>> wrote:
> What API's are available for Dataflow Analysis in Clang? I want to create a
> standalone tool (using libTooling) to analyse C source code.
> 
> 
> 
> 
> --
> View this message in context: http://clang-developers.42468.n3.nabble.com/Data-flow-analysis-in-Clang-tp4042447.html <http://clang-developers.42468.n3.nabble.com/Data-flow-analysis-in-Clang-tp4042447.html>
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev <http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev <http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141114/c8e34d7f/attachment.html>


More information about the cfe-dev mailing list