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:
parent
c21f219ab7
commit
8f09f3af07
2 changed files with 10 additions and 11 deletions
|
@ -257,7 +257,12 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinding getOwner() {
|
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
|
@Override
|
||||||
|
|
|
@ -2434,19 +2434,13 @@ public class CPPVisitor extends ASTQueries {
|
||||||
* Searches for the function enclosing the given node. May return <code>null</code>.
|
* Searches for the function enclosing the given node. May return <code>null</code>.
|
||||||
*/
|
*/
|
||||||
public static IBinding findEnclosingFunction(IASTNode node) {
|
public static IBinding findEnclosingFunction(IASTNode node) {
|
||||||
IASTDeclarator dtor = null;
|
while (node != null && !(node instanceof IASTFunctionDefinition)) {
|
||||||
while (node != null) {
|
|
||||||
if (node instanceof IASTFunctionDeclarator) {
|
|
||||||
dtor = (IASTDeclarator) node;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (node instanceof IASTFunctionDefinition) {
|
|
||||||
dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
node= node.getParent();
|
node= node.getParent();
|
||||||
}
|
}
|
||||||
|
if (node == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IASTDeclarator dtor= findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator());
|
||||||
if (dtor != null) {
|
if (dtor != null) {
|
||||||
IASTName name= dtor.getName();
|
IASTName name= dtor.getName();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue