1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 395875 - An alternative fix that preserves semantics of

CPPVisitor.findEnclosingFunction method.
This commit is contained in:
Sergey Prigogin 2012-12-07 14:32:29 -08:00
parent c21f219ab7
commit 8f09f3af07
2 changed files with 10 additions and 11 deletions

View file

@ -257,7 +257,12 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
@Override
public IBinding getOwner() {
return CPPVisitor.findEnclosingFunction(fDeclarations[0]);
IASTFunctionDeclarator decl =
CPPVisitor.findAncestorWithType(fDeclarations[0], IASTFunctionDeclarator.class);
if (decl == null)
return null;
IASTName name= decl.getName();
return name != null ? name.resolveBinding() : null;
}
@Override

View file

@ -2434,19 +2434,13 @@ public class CPPVisitor extends ASTQueries {
* Searches for the function enclosing the given node. May return <code>null</code>.
*/
public static IBinding findEnclosingFunction(IASTNode node) {
IASTDeclarator dtor = null;
while (node != null) {
if (node instanceof IASTFunctionDeclarator) {
dtor = (IASTDeclarator) node;
break;
}
if (node instanceof IASTFunctionDefinition) {
dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator());
break;
}
while (node != null && !(node instanceof IASTFunctionDefinition)) {
node= node.getParent();
}
if (node == null)
return null;
IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator());
if (dtor != null) {
IASTName name= dtor.getName();
if (name != null) {