mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Patch for Hoda Amer:
- Fix for bug 36604 : NPE in CModelBuilder for given input
This commit is contained in:
parent
f2da937be0
commit
8fc0923c61
1 changed files with 22 additions and 6 deletions
|
@ -372,7 +372,11 @@ public class CModelBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VariableDeclaration createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
|
protected VariableDeclaration createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
|
||||||
String variableName = declarator.getName().toString();
|
Name domName = ( declarator.getDeclarator() != null ) ?
|
||||||
|
declarator.getDeclarator().getName() :
|
||||||
|
declarator.getName();
|
||||||
|
|
||||||
|
String variableName = domName.toString();
|
||||||
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
|
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
|
||||||
|
|
||||||
VariableDeclaration element = null;
|
VariableDeclaration element = null;
|
||||||
|
@ -403,7 +407,7 @@ public class CModelBuilder {
|
||||||
parent.addChild( element );
|
parent.addChild( element );
|
||||||
|
|
||||||
// set position
|
// set position
|
||||||
element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
|
element.setIdPos( domName.getStartOffset(), domName.length() );
|
||||||
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
||||||
|
|
||||||
this.newElements.put(element, element.getElementInfo());
|
this.newElements.put(element, element.getElementInfo());
|
||||||
|
@ -411,7 +415,11 @@ public class CModelBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FunctionDeclaration createFunctionSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator, ParameterDeclarationClause pdc, boolean isTemplate){
|
protected FunctionDeclaration createFunctionSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator, ParameterDeclarationClause pdc, boolean isTemplate){
|
||||||
String declaratorName = declarator.getName().toString();
|
Name domName = ( declarator.getDeclarator() != null ) ?
|
||||||
|
declarator.getDeclarator().getName() :
|
||||||
|
declarator.getName();
|
||||||
|
|
||||||
|
String declaratorName = domName.toString();
|
||||||
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
|
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
|
||||||
// getParameterTypes
|
// getParameterTypes
|
||||||
List parameterList = pdc.getDeclarations();
|
List parameterList = pdc.getDeclarations();
|
||||||
|
@ -482,7 +490,7 @@ public class CModelBuilder {
|
||||||
parent.addChild( element );
|
parent.addChild( element );
|
||||||
|
|
||||||
// hook up the offsets
|
// hook up the offsets
|
||||||
element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
|
element.setIdPos( domName.getStartOffset(), domName.length() );
|
||||||
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
||||||
this.newElements.put(element, element.getElementInfo());
|
this.newElements.put(element, element.getElementInfo());
|
||||||
return element;
|
return element;
|
||||||
|
@ -504,10 +512,14 @@ public class CModelBuilder {
|
||||||
|| ( parent instanceof INamespace ))
|
|| ( parent instanceof INamespace ))
|
||||||
{
|
{
|
||||||
element = new VariableDeclaration(parent, declaratorName);
|
element = new VariableDeclaration(parent, declaratorName);
|
||||||
|
} else if( parent instanceof IStructure){
|
||||||
|
Field newElement = new Field(parent, declaratorName);
|
||||||
|
newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
|
||||||
|
element = newElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer typeName = new StringBuffer();
|
StringBuffer typeName = new StringBuffer();
|
||||||
typeName.append(getType(simpleDeclaration, declarator));
|
typeName.append(getType(simpleDeclaration, declarator));
|
||||||
typeName.append("(*)");
|
|
||||||
if(parameterTypes.length > 0){
|
if(parameterTypes.length > 0){
|
||||||
typeName.append("(");
|
typeName.append("(");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -589,6 +601,10 @@ public class CModelBuilder {
|
||||||
type.append(getDeclarationType(declaration));
|
type.append(getDeclarationType(declaration));
|
||||||
// add pointerr or reference from declarator if any
|
// add pointerr or reference from declarator if any
|
||||||
type.append(getDeclaratorPointerOperation(declarator));
|
type.append(getDeclaratorPointerOperation(declarator));
|
||||||
|
// pointer to function or array of functions
|
||||||
|
if(declarator.getDeclarator() != null)
|
||||||
|
type.append("(*)");
|
||||||
|
// arrays
|
||||||
type.append(getDeclaratorArrayQualifiers(declarator));
|
type.append(getDeclaratorArrayQualifiers(declarator));
|
||||||
return type.toString();
|
return type.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue