Vote count:
0
This is a question about navigating the clang AST.
I need to find all the names that are visible from a position in a translation unit. I have problems handling situations like this:
void foo() {
{
int x;
}
// no 'x' here
for (int i = 0; i < 2; i++) {
int y;
}
// no 'i', no 'y'
}
It seems that clang's DeclContext class is the base class of all the constructs that can act as a declaration context. Much to my surprise, CompoundStmt and ForStmt do not derive from DeclContext - although they do create scopes. When I follow the parent chain (via Decl::getDeclContext and DeclContext::getParent) from, say, the declaration of 'x', it jumps directly to the FunctionDecl.
Maybe I am missing something here. It seems that the following phases of the C/C++ compiler need to know the scope of the names. How do they do it?
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire