Accessing the declarations that are in scope at an AST node

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing the declarations that are in scope at an AST node

Alastair Donaldson
Hi all

I am new to working with the clang AST.

For some analysis I am doing, I'd like to be able to iterate through all the declarations that are in scope at a given AST node.

For instance, in:

int g;

void foo(int x) {
  int y;
  { int z; }
  { int a;
     y = a; // *
  }
}

at the Stmt node for * I would like to know which variables are in scope, and see g, x, y and a but not a.

I have been looking for some way to get a symbol table object that would contain this info, but have not found what I am looking for.

Could someone please point me in the right direction?

Thanks!

Ally
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the declarations that are in scope at an AST node

Alastair Donaldson
Sorry, I meant "but not z"