[cfe-dev] Shadowed local variables

Laszlo Nagy rizsotto.mailinglist at gmail.com
Wed Aug 21 03:38:04 PDT 2013


Hi Peter,

the pointer returned by getDecl() is a perfect unique identifier inside
your program. Should feel all right! ;) If you want to report to the user,
you can refer with the name and the line number it was declared.

Regards,
Laszlo


On Tue, Aug 20, 2013 at 1:32 PM, Peter Jacobsen <jacobsen.peter at gmail.com>wrote:

>  Hi,
>
> Referring to the code below, as I climb the Clang AST, when I arrive at the
> DeclRefExpr refering to x on the lhs of the assignment x=2, how do I detect
> that it is the block scope x, rather than the function scope x?
>
> void f()
> {
>   int x;
>   x=1;
>   {
>     int x;
>     x=2;
>   }
>   gx=x;
> }
>
> I need unique identifiers for the each x, so my symbolic execution
> calculates the correct value for gx. Currently I am calling getDecl() and
> then getQualifiedNameAsString().  I have tried calling getDeclContext, but
> in references to both xs, I get a CXXMethod as the context.
> Presumably I could use the value of the pointer returned by getDecl(), but
> this doesn’t feel right.
>
> Any help much appreciated.
>
> Thanks,
> Peter
>
>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/Shadowed-local-variables-tp4033981.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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130821/b6c47135/attachment.html>


More information about the cfe-dev mailing list