Accessing the declarations that are in scope at an AST node

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

Sorry, I meant "but not z"