[cfe-dev] How to get global variables' SymbolRef?
Jordan Rose
jordan_rose at apple.com
Thu Nov 14 09:10:17 PST 2013
On Nov 14, 2013, at 2:37 , edward jiamu <edwardjiamu at gmail.com> wrote:
> Thank you for your advice very much.
>
> At last the problem is solved by this way:
> 1) record the "VarDecl* p" of global variable in the checkASTDecl
> 2) get the SymbolRef by recorded "VarDecl* p" in the evalCall
> SVal sv = state->getLValue(p, C.getLocationContext());
> const SymbolRef symRef = sv.getAsSymbol();
>
> Do this to get the unique id of global variables and local variables.
VarDecls are never symbolic, so symRef will always be null. Unless I’m forgetting something? The contents will be symbolic, but you only asked for the lvalue (the location).
Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131114/ea9da6e1/attachment.html>
More information about the cfe-dev
mailing list