Hi
If you are already visiting the AST, you can also visit the visibility labels (implement the corresponding visit() method and enable them) and remember the last visibility you have encountered on the way. You probably will need to have a stack of visibilities,
as you might overwrite it in the nested classes. I'm not sure if there is already some functionality like this lingering somewhere. This is one possibility.
Otherwise, you can look for this information in the bindings, if you are familiar with them. ICPPClassType has a method getVisibility(IBinding). I guess you can call it on the "Enclosing" binding with the "Nested" binding as argument.
I would suggest the latter.
I hope this helps!
Thomas
Hi,
Assume I have this class definition:
class
Enclosing {
private
:
int
x;
/*
start of Nested class declaration */
class
Nested {
int
y;
void
NestedFun(Enclosing *e) {
cout<<e->x;
//
works fine: nested class can access
//
private members of Enclosing class
}
};
//
declaration Nested class ends here
};
//
declaration Enclosing class ends here
Now ASTVisitor will give me callback "public int visit(IASTDeclaration decl)" for class Enclosing
and later Nested. How
can I get class Nested's accessibility within Enclosing?
Thanks.
Ming