mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Follow up 181305, binding returns empty name for 'void (fn)();'
This commit is contained in:
parent
2b14d7a898
commit
a8ced8a5d3
3 changed files with 32 additions and 24 deletions
|
@ -3603,6 +3603,7 @@ public class AST2Tests extends AST2BaseTest {
|
|||
IBinding binding= idExpr.getName().resolveBinding();
|
||||
assertTrue(lang.toString(), binding instanceof IFunction);
|
||||
assertFalse(lang.toString(), binding instanceof IProblemBinding);
|
||||
assertEquals(binding.getName(), "decl");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -157,12 +157,21 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
IASTFunctionDeclarator dtor = ( definition != null ) ? definition : declarators[0];
|
||||
return dtor.getName().toString();
|
||||
return getASTName().toString();
|
||||
}
|
||||
|
||||
public char[] getNameCharArray(){
|
||||
IASTFunctionDeclarator dtor = ( definition != null ) ? definition : declarators[0];
|
||||
return dtor.getName().toCharArray();
|
||||
return getASTName().toCharArray();
|
||||
}
|
||||
|
||||
private IASTName getASTName() {
|
||||
IASTDeclarator dtor = ( definition != null ) ? definition : declarators[0];
|
||||
IASTDeclarator nested= dtor.getNestedDeclarator();
|
||||
while (nested != null && nested.getPointerOperators().length == 0) {
|
||||
dtor= nested;
|
||||
nested= nested.getNestedDeclarator();
|
||||
}
|
||||
return dtor.getName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -155,11 +155,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
else
|
||||
declarations = new ICPPASTFunctionDeclarator [] { declarator };
|
||||
|
||||
IASTName name = declarator.getName();
|
||||
if( name instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||
name = ns[ ns.length - 1 ];
|
||||
}
|
||||
IASTName name= getASTName();
|
||||
name.setBinding( this );
|
||||
}
|
||||
}
|
||||
|
@ -283,35 +279,37 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
IASTName name = (definition != null ) ? definition.getName() : declarations[0].getName();
|
||||
if( name instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||
name = ns[ ns.length - 1 ];
|
||||
}
|
||||
return name.toString();
|
||||
return getASTName().toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
IASTName name = (definition != null ) ? definition.getName() : declarations[0].getName();
|
||||
return getASTName().toCharArray();
|
||||
}
|
||||
|
||||
private IASTName getASTName() {
|
||||
IASTDeclarator dtor = ( definition != null ) ? definition : declarations[0];
|
||||
IASTDeclarator nested= dtor.getNestedDeclarator();
|
||||
while (nested != null) {
|
||||
dtor= nested;
|
||||
nested= nested.getNestedDeclarator();
|
||||
}
|
||||
IASTName name= dtor.getName();
|
||||
if( name instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||
name = ns[ ns.length - 1 ];
|
||||
}
|
||||
return name.toCharArray();
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
IASTName n = definition != null ? definition.getName() : declarations[0].getName();
|
||||
if( n instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||
n = ns[ ns.length - 1 ];
|
||||
}
|
||||
IASTName n= getASTName();
|
||||
IScope scope = CPPVisitor.getContainingScope( n );
|
||||
if( scope instanceof ICPPClassScope ){
|
||||
ICPPASTDeclSpecifier declSpec = null;
|
||||
|
@ -497,7 +495,7 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
|
||||
static public boolean hasStorageClass( ICPPInternalFunction function, int storage ){
|
||||
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) function.getDefinition();
|
||||
IASTNode[] ds = (IASTNode[]) function.getDeclarations();
|
||||
IASTNode[] ds = function.getDeclarations();
|
||||
|
||||
int i = -1;
|
||||
do{
|
||||
|
|
Loading…
Add table
Reference in a new issue