[cfe-dev] Shadowed local variables
peter jacobsen
jacobsen.peter at gmail.com
Fri Aug 23 11:35:44 PDT 2013
Hi Laszlo,
Thanks for this.
Regards,
Peter
On Wed, Aug 21, 2013 at 11:38 AM, Laszlo Nagy <
rizsotto.mailinglist at gmail.com> wrote:
> 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/20130823/3faf4434/attachment.html>
More information about the cfe-dev
mailing list