[cfe-dev] Dataflow analysis with Libtooling and LiveVariables

Saheel Godhane srgodhane at ucdavis.edu
Mon Dec 15 15:34:05 PST 2014


Thank you so much for your replies! Please find my comments below.

On Mon, Dec 15, 2014 at 2:10 PM, Anna Zaks <ganna at apple.com> wrote:
>
>
> On Dec 15, 2014, at 5:01 AM, Manuel Klimek <klimek at google.com> wrote:
>
>
> LiveVariables operates on the front-end CFG, which contains the references
> to the AST nodes in its basic blocks.  You should be getting precise
> liveness information for every statement.
>

> LiveVariables is currently used by the DeadStoresChecker, so that would be
> a good point of reference. DeadStoresChecker talks to the LiveVariables
> through the Observer.
>

Hmm... I noticed that DebugChecker also uses LiveVariables (though very
slightly), so taking that as a reference I wrote a checker and have been
able to get statement level liveness information.

By the way, is there def-use and use-def chains also implemented (used?) in
Clang? At least, I couldn't find it anywhere.


>
> I am not sure why liveness information is not dumped... I would try to
> debug this as well as the analyzer's version to see what's missing.
>

Debug using GDB? Or is there is an easier way? I tried GDB but as usual it
was a bit messy, so I gave up and started writing a checker.


> Surely I am missing something here but I am not able to figure out.
>> Perhaps my instantiation of AnalysisDeclContextManager is incorrect?
>> I started out with overriding VisitVarDecl() in the RecursiveASTVisitor
>> but then realized that to call LiveVariables::computeLiveness() I need an
>> AnalysisDeclContext object which works only with block-level declarations
>> (am I correct?), so switched to VisitFunctionDecl().
>>
>> Any help on how to get this working, or whether I should just switch over
>> to writing a Checker, will be greatly appreciated! :)
>>
>
> That depends:
> If what you want in the end is a static analysis check, then yes, write a
> checker. If you want  to drive refactorings from the results, then the
> right approach is libTooling; but as you discovered libTooling is not
> integrated well with the CFG yet (that needs some work)
>
>
Thanks for the hint! Indeed, all I want to do is some static analysis. And
I am finding writing a checker quite easy and useful for that purpose.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141215/98546546/attachment.html>


More information about the cfe-dev mailing list