Hi, Consider:
void foo() { // a scope { enum { Foo }; } // another scope { int x; enum { Foo }; int y; } } I want to identify the source ranges where the two (distinct) Foo are visible, given a pointer to their respective EnumConstantDecl. I have tried with the various Parent() methods - getParentFunctionOrMethod() looked like a good candidate - but it doesn't look like blocks constitute scopes. For example, calling getParentFunctionOrMethod()->dumpCeclContext() on either enumerators prints the same thing, namely: enum { Foo }; int x; enum { Foo }; int y; I found a solution that involves going up to the nearest DeclContext, then look down the tree (using an AST matcher) for the CompoundStmt that contains a DeclStmt that declares an EnumDecl which has the target EnumConstantDecl. However, I am thinking that there must be an easier way to do this - after all, the two Foo *are* in different scopes and the code generation back-end needs to know this. I would expect the scopes to be represented in the AST and it looks like DeclContext is just that. I am new to the AST library so I may be missing something obvious... Jean-Louis _______________________________________________ cfe-users mailing list cfe-users@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users