[cfe-dev] Read/Write Accesses of global variables in a Function body...

Peter clang_llvm_123-4 at yahoo.de
Mon Dec 19 13:30:45 PST 2011


Thanks Eli, you helped me a lot...!!!

One last question, is there any way to find that a
a DeclRefExpr only occurred on the left hand site?

I can overwrite 'VisitBinaryOperator' to see if it occurred

on the left hand site. But how do I know, that it doesn't occur
on the right hand site?

'VisitDeclRefExpr' finds any occurrences...and it looks like 'DeclRefExpr' doesn't tell
me on which site is...


Thanks a lot!!!!
Peter






________________________________
 Von: Eli Friedman <eli.friedman at gmail.com>
An: Peter <clang_llvm_123-4 at yahoo.de> 
Cc: "cfe-dev at cs.uiuc.edu" <cfe-dev at cs.uiuc.edu> 
Gesendet: 21:06 Montag, 19.Dezember 2011
Betreff: Re: [cfe-dev] Read/Write Accesses of global variables in a Function body...
 
On Mon, Dec 19, 2011 at 11:58 AM, Peter <clang_llvm_123-4 at yahoo.de> wrote:
> Thanks a lot Eli,... for your reply...
>
>>having the AST visitor look for assignment operators rather than doing that
>> part yourself.
> I did everything myself because I wanted to start from a given function...
> How do I make sure that my visitor only visits the body of a given function?
> Do I
> have to implement two different visitors, one that only implements
> 'VisitFunctionDecl' to
> find the function in question and then once found, call the other visitor
> with the function body
> to only visit the 'DeclRefExpr' expressions?

From the docs for RecursiveASTVisitor, it looks like you can override
TraverseFunctionDecl to suppress recursion if necessary.

>>hasLinkage(), or maybe hasGlobalStorage()?
> ...hasLinkage is what I was looking for... ;)
>
>>If you're just looking for simple assignments,
> I guess for the write access I do, but for the read access I need any
> occurrence within
> the function body. Does that mean I have to implement a visitor method for
> any possible rvalue
> expression, or is it maybe enough to only visit the 'DeclRefExpr' ?

Any use of the variable will have an associated DeclRefExpr, so you
won't miss any references to the variable.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111219/9ac29c09/attachment.html>


More information about the cfe-dev mailing list