[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Fix for bug 36604 : NPE in CModelBuilder for given input
|
Thanks
Hoda
Index: parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.14
diff -u -r1.14 CModelBuilder.java
--- parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 17 Apr 2003 13:41:43 -0000 1.14
+++ parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 17 Apr 2003 14:50:40 -0000
@@ -372,7 +372,11 @@
}
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();
VariableDeclaration element = null;
@@ -403,7 +407,7 @@
parent.addChild( element );
// set position
- element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
+ element.setIdPos( domName.getStartOffset(), domName.length() );
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
this.newElements.put(element, element.getElementInfo());
@@ -411,7 +415,11 @@
}
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();
// getParameterTypes
List parameterList = pdc.getDeclarations();
@@ -482,7 +490,7 @@
parent.addChild( element );
// hook up the offsets
- element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
+ element.setIdPos( domName.getStartOffset(), domName.length() );
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
this.newElements.put(element, element.getElementInfo());
return element;
@@ -504,10 +512,14 @@
|| ( parent instanceof INamespace ))
{
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();
typeName.append(getType(simpleDeclaration, declarator));
- typeName.append("(*)");
if(parameterTypes.length > 0){
typeName.append("(");
int i = 0;
@@ -589,6 +601,10 @@
type.append(getDeclarationType(declaration));
// add pointerr or reference from declarator if any
type.append(getDeclaratorPointerOperation(declarator));
+ // pointer to function or array of functions
+ if(declarator.getDeclarator() != null)
+ type.append("(*)");
+ // arrays
type.append(getDeclaratorArrayQualifiers(declarator));
return type.toString();
}