[cfe-dev] which class represent variable scope ?

kevinlynx kevinlynx at gmail.com
Fri Jan 11 00:31:05 PST 2013


You mean I cann't get scope information right now ?   


------------------ Original ------------------
From:  "John McCall"<rjmccall at apple.com>;
Date:  Fri, Jan 11, 2013 04:22 PM
To:  "kevinlynx"<kevinlynx at gmail.com>; 
Cc:  "cfe-dev"<cfe-dev at cs.uiuc.edu>; 
Subject:  Re: [cfe-dev] which class represent variable scope ?



On Jan 10, 2013, at 9:05 PM, kevinlynx <kevinlynx at gmail.com> wrote:
> For example:
> 
>     void func() {
>         unsigned a;
>         {
>              unsigned b;
>         }
>    }
> 
> I want to know whether `a` and `b` is in the same code scope.  DeclContext does NOT work on this, which means `a` and `b` have the same DeclContext (a function decl context). I googled and found someone have already asked this question but didn't get an answer. 

Scope is not recorded directly in the AST.  It would be both possible and reasonable to provide an API that recomputes the language-specific notion of the scope of each declaration in a function.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130111/f869f1a3/attachment.html>


More information about the cfe-dev mailing list