[cfe-dev] Data flow analysis in Clang

Manuel Klimek klimek at google.com
Sat Nov 15 09:13:57 PST 2014


On Sat Nov 15 2014 at 1:41:51 PM Vanush Vaswani <vanush at gmail.com> wrote:

> Can you use this in the context of libTooling?
>

Yep. Look at clang-tidy to see how you can hook up static analyzer checks
to a clang tool (clang-tidy is written on top of libtooling).

The simples thing for now is probably make your check either a static
analyzer check directly and use clang-tidy as a driver to run it, or
implement a clang-tidy check (where you have access to the CFG, just like
clang's diagnostics, but not to the path sensitive analysis).


>
> On Sat, Nov 15, 2014 at 4:58 AM, Ted Kremenek <kremenek at apple.com> wrote:
> > 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> 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>
> 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
> >>> Sent from the Clang Developers mailing list archive at Nabble.com.
> >>> _______________________________________________
> >>> cfe-dev mailing list
> >>> cfe-dev at cs.uiuc.edu
> >>> 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
> >>
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > 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
> >
> _______________________________________________
> 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/20141115/5f7c272f/attachment.html>


More information about the cfe-dev mailing list