mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Hoda Amer
- Added references to variables in solution of bug#42453:Expression result types not computed - Solution to bug#42560: Class Cast Exception during Method definition
This commit is contained in:
parent
dec04e4d8b
commit
63ed749357
3 changed files with 178 additions and 101 deletions
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
|
import org.eclipse.cdt.core.parser.ast.IASTFieldReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunctionReference;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
@ -525,21 +526,26 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
public void testQualifiedNameReferences() throws Exception
|
public void testQualifiedNameReferences() throws Exception
|
||||||
{
|
{
|
||||||
Iterator i = parse( "class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n" ).getDeclarations();
|
try { // This is to prove that there are no exceptions
|
||||||
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
// Used to cause AST Semantic exception
|
||||||
Iterator j = getDeclarations(classA);
|
Iterator i = parse( "class A{ class B{ class C { public: int cMethod(); }; }; }; \n int A::B::C::cMethod() {}; \n" ).getDeclarations();
|
||||||
IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)j.next()).getTypeSpecifier();
|
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||||
Iterator k = getDeclarations(classB);
|
Iterator j = getDeclarations(classA);
|
||||||
IASTClassSpecifier classC = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)k.next()).getTypeSpecifier();
|
IASTClassSpecifier classB = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)j.next()).getTypeSpecifier();
|
||||||
|
Iterator k = getDeclarations(classB);
|
||||||
|
IASTClassSpecifier classC = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)k.next()).getTypeSpecifier();
|
||||||
|
|
||||||
// Note : this used to be considered a function, not a method
|
// Note : this used to be considered a function, not a method
|
||||||
IASTMethod method = (IASTMethod)i.next();
|
IASTMethod method = (IASTMethod)i.next();
|
||||||
|
|
||||||
assertEquals( callback.getReferences().size(), 3 );
|
assertEquals( callback.getReferences().size(), 3 );
|
||||||
Iterator references = callback.getReferences().iterator();
|
Iterator references = callback.getReferences().iterator();
|
||||||
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classA );
|
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classA );
|
||||||
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classB );
|
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classB );
|
||||||
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classC );
|
assertEquals( ((IASTClassReference)references.next()).getReferencedElement(), classC );
|
||||||
|
}catch (Exception e){
|
||||||
|
fail();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsConstructor() throws Exception
|
public void testIsConstructor() throws Exception
|
||||||
|
@ -619,4 +625,32 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
IASTField charA = (IASTField)sub.next();
|
IASTField charA = (IASTField)sub.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testExpressionResultValueWithSimpleTypes() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse ("int f(int, int); \n int f(int); \n int x = f(1, 2+3);").getDeclarations();
|
||||||
|
IASTFunction f1 = (IASTFunction) i.next();
|
||||||
|
IASTFunction f2 = (IASTFunction) i.next();
|
||||||
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
|
Iterator references = callback.getReferences().iterator();
|
||||||
|
IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
|
||||||
|
assertEquals( fr1.getReferencedElement(), f1 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testExpressionResultValueWithReferenceTypes() throws Exception
|
||||||
|
{
|
||||||
|
Iterator i = parse ("class A{}a; \n int f(A a); \n int x = f(a);").getDeclarations();
|
||||||
|
IASTVariable a = (IASTVariable) i.next();
|
||||||
|
IASTFunction f1 = (IASTFunction) i.next();
|
||||||
|
IASTVariable x = (IASTVariable) i.next();
|
||||||
|
Iterator references = callback.getReferences().iterator();
|
||||||
|
IASTClassReference clr1 = (IASTClassReference) references.next();
|
||||||
|
IASTFunctionReference fr1 = (IASTFunctionReference) references.next();
|
||||||
|
IASTVariableReference ar1 = (IASTVariableReference) references.next();
|
||||||
|
IASTFunctionReference fr2 = (IASTFunctionReference) references.next();
|
||||||
|
assertEquals( ar1.getReferencedElement(), a );
|
||||||
|
assertEquals( fr2.getReferencedElement(), f1 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-09-04 Hoda Amer
|
||||||
|
- Added references to variables in solution of bug#42453:Expression result types not computed
|
||||||
|
- Solution to bug#42560: Class Cast Exception during Method definition
|
||||||
|
|
||||||
2003-09-04 Alain Magloire
|
2003-09-04 Alain Magloire
|
||||||
|
|
||||||
The IProgressMonitor.setCancelled() is incorrect, it tries to access
|
The IProgressMonitor.setCancelled() is incorrect, it tries to access
|
||||||
|
@ -16,7 +20,7 @@
|
||||||
whole ITOkenDuple for the typeId instead of just the string.
|
whole ITOkenDuple for the typeId instead of just the string.
|
||||||
- Changed the ASTExpression in both quick and complete packages and
|
- Changed the ASTExpression in both quick and complete packages and
|
||||||
deleted the "id" parameter.
|
deleted the "id" parameter.
|
||||||
- Added partial solution to bug #42453: Exception result types not computed.
|
- Added partial solution to bug #42453:Expression result types not computed.
|
||||||
Now they are computed for simple types only.
|
Now they are computed for simple types only.
|
||||||
|
|
||||||
2003-09-03 David Inglis
|
2003-09-03 David Inglis
|
||||||
|
|
|
@ -61,6 +61,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescripto
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.ASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
|
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
|
||||||
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
|
||||||
|
@ -718,24 +719,26 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
IContainerSymbol startingScope = scopeToSymbol( scope );
|
IContainerSymbol startingScope = scopeToSymbol( scope );
|
||||||
|
|
||||||
//look up typeId & add to references
|
//look up typeId & add to references
|
||||||
if( typeId != null )
|
ISymbol symbol = null;
|
||||||
lookupQualifiedName( startingScope, typeId, references, false );
|
if( typeId != null ){
|
||||||
|
symbol = lookupQualifiedName( startingScope, typeId, references, false );
|
||||||
|
}
|
||||||
|
|
||||||
if (kind == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
|
if (kind == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
|
||||||
ITokenDuple functionId = ((ASTExpression)lhs).getTypeId();
|
ITokenDuple functionId = ((ASTExpression)lhs).getTypeId();
|
||||||
List parameters = ((ASTExpression)rhs).getResultType();
|
List parameters = ((ASTExpression)rhs).getResultType();
|
||||||
lookupQualifiedName(startingScope, functionId, TypeInfo.t_function, parameters, references, false);
|
symbol = lookupQualifiedName(startingScope, functionId, TypeInfo.t_function, parameters, references, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
|
ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
|
||||||
typeId, literal, newDescriptor, references);
|
typeId, literal, newDescriptor, references);
|
||||||
|
|
||||||
expression.setResultType (getExpressionResultType(expression));
|
expression.setResultType (getExpressionResultType(expression, symbol));
|
||||||
|
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List getExpressionResultType(IASTExpression expression){
|
protected List getExpressionResultType(IASTExpression expression, ISymbol symbol){
|
||||||
List result = new ArrayList();
|
List result = new ArrayList();
|
||||||
|
|
||||||
if (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY) {
|
if (expression.getExpressionKind() == IASTExpression.Kind.PRIMARY_EMPTY) {
|
||||||
|
@ -768,6 +771,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
result.add(info);
|
result.add(info);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
if (expression.getExpressionKind() == IASTExpression.Kind.ID_EXPRESSION){
|
||||||
|
TypeInfo info = new TypeInfo();
|
||||||
|
info.setType(TypeInfo.t_type);
|
||||||
|
if(symbol != null)
|
||||||
|
info.setTypeSymbol(symbol);
|
||||||
|
result.add(info);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
if ((expression.getExpressionKind() == IASTExpression.Kind.ADDITIVE_PLUS)
|
if ((expression.getExpressionKind() == IASTExpression.Kind.ADDITIVE_PLUS)
|
||||||
|| (expression.getExpressionKind() == IASTExpression.Kind.ADDITIVE_MINUS) ){
|
|| (expression.getExpressionKind() == IASTExpression.Kind.ADDITIVE_MINUS) ){
|
||||||
ASTExpression right = (ASTExpression)expression.getLHSExpression();
|
ASTExpression right = (ASTExpression)expression.getLHSExpression();
|
||||||
|
@ -798,9 +809,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
|
if(expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
|
||||||
TypeInfo type = new TypeInfo();
|
TypeInfo info = new TypeInfo();
|
||||||
type.setType(TypeInfo.t_function);
|
info.setType(TypeInfo.t_function);
|
||||||
result.add(type);
|
if(symbol != null)
|
||||||
|
info.setTypeSymbol(symbol);
|
||||||
|
result.add(info);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -1012,8 +1025,16 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
if((parentScope != null) && (parentScope.getType() == TypeInfo.t_class)){
|
if((parentScope != null) && (parentScope.getType() == TypeInfo.t_class)){
|
||||||
// find out the visibility of the method's declaration
|
// find out the visibility of the method's declaration
|
||||||
List functionReferences = new ArrayList();
|
List functionReferences = new ArrayList();
|
||||||
|
List functionParameters = new LinkedList();
|
||||||
|
// the lookup requires a list of type infos
|
||||||
|
// instead of a list of IASTParameterDeclaration
|
||||||
|
Iterator p = parameters.iterator();
|
||||||
|
while (p.hasNext()){
|
||||||
|
ASTParameterDeclaration param = (ASTParameterDeclaration)p.next();
|
||||||
|
functionParameters.add(getParameterTypeInfo(param));
|
||||||
|
}
|
||||||
IParameterizedSymbol methodDeclaration =
|
IParameterizedSymbol methodDeclaration =
|
||||||
(IParameterizedSymbol) lookupQualifiedName(parentScope, functionName, TypeInfo.t_function, parameters, 0, functionReferences, false);
|
(IParameterizedSymbol) lookupQualifiedName(parentScope, functionName, TypeInfo.t_function, functionParameters, 0, functionReferences, false);
|
||||||
if(methodDeclaration != null){
|
if(methodDeclaration != null){
|
||||||
ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next();
|
ASTMethodReference reference = (ASTMethodReference) functionReferences.iterator().next();
|
||||||
visibility = ((IASTMethod)reference.getReferencedElement()).getVisiblity();
|
visibility = ((IASTMethod)reference.getReferencedElement()).getVisiblity();
|
||||||
|
@ -1074,92 +1095,108 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected TypeInfo getParameterTypeInfo( IASTAbstractDeclaration absDecl)throws ASTSemanticException{
|
||||||
* @param symbol
|
TypeInfo type = new TypeInfo();
|
||||||
* @param returnType
|
if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
|
||||||
*/
|
{
|
||||||
protected void setParameter(IParameterizedSymbol symbol, IASTAbstractDeclaration absDecl, boolean isParameter, List references) throws ASTSemanticException
|
IASTSimpleTypeSpecifier.Type kind = ((IASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getType();
|
||||||
{
|
if( kind == IASTSimpleTypeSpecifier.Type.BOOL )
|
||||||
if (absDecl.getTypeSpecifier() == null)
|
type.setType(TypeInfo.t_bool);
|
||||||
return;
|
else if( kind == IASTSimpleTypeSpecifier.Type.CHAR )
|
||||||
|
type.setType(TypeInfo.t_char);
|
||||||
TypeInfo.eType type = null;
|
else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE )
|
||||||
ISymbol xrefSymbol = null;
|
type.setType(TypeInfo.t_double);
|
||||||
List newReferences = null;
|
else if( kind == IASTSimpleTypeSpecifier.Type.FLOAT )
|
||||||
if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
|
type.setType(TypeInfo.t_float);
|
||||||
{
|
else if( kind == IASTSimpleTypeSpecifier.Type.INT )
|
||||||
IASTSimpleTypeSpecifier.Type kind = ((IASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getType();
|
type.setType(TypeInfo.t_int);
|
||||||
if( kind == IASTSimpleTypeSpecifier.Type.BOOL )
|
else if( kind == IASTSimpleTypeSpecifier.Type.VOID )
|
||||||
type = TypeInfo.t_bool;
|
type.setType(TypeInfo.t_void);
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.CHAR )
|
else if( kind == IASTSimpleTypeSpecifier.Type.WCHAR_T)
|
||||||
type = TypeInfo.t_char;
|
type.setType(TypeInfo.t_wchar_t);
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.DOUBLE )
|
else if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
||||||
type = TypeInfo.t_double;
|
type.setType(TypeInfo.t_type);
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.FLOAT )
|
|
||||||
type = TypeInfo.t_float;
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.INT )
|
|
||||||
type = TypeInfo.t_int;
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.VOID )
|
|
||||||
type = TypeInfo.t_void;
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.WCHAR_T)
|
|
||||||
type = TypeInfo.t_wchar_t;
|
|
||||||
else if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
|
||||||
{
|
|
||||||
type = TypeInfo.t_type;
|
|
||||||
xrefSymbol = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getSymbol();
|
|
||||||
newReferences = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getReferences();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
else if( absDecl.getTypeSpecifier() instanceof IASTClassSpecifier )
|
|
||||||
{
|
|
||||||
ASTClassKind kind = ((IASTClassSpecifier)absDecl.getTypeSpecifier()).getClassKind();
|
|
||||||
if( kind == ASTClassKind.CLASS )
|
|
||||||
type = TypeInfo.t_class;
|
|
||||||
else if( kind == ASTClassKind.STRUCT )
|
|
||||||
type = TypeInfo.t_struct;
|
|
||||||
else if( kind == ASTClassKind.UNION )
|
|
||||||
type = TypeInfo.t_union;
|
|
||||||
else
|
else
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
else if( absDecl.getTypeSpecifier() instanceof IASTEnumerationSpecifier )
|
else if( absDecl.getTypeSpecifier() instanceof IASTClassSpecifier )
|
||||||
{
|
{
|
||||||
type = TypeInfo.t_enumeration;
|
ASTClassKind kind = ((IASTClassSpecifier)absDecl.getTypeSpecifier()).getClassKind();
|
||||||
}
|
if( kind == ASTClassKind.CLASS )
|
||||||
else if( absDecl.getTypeSpecifier() instanceof IASTElaboratedTypeSpecifier )
|
type.setType(TypeInfo.t_class);
|
||||||
{
|
else if( kind == ASTClassKind.STRUCT )
|
||||||
|
type.setType(TypeInfo.t_struct);
|
||||||
|
else if( kind == ASTClassKind.UNION )
|
||||||
|
type.setType(TypeInfo.t_union);
|
||||||
|
else
|
||||||
|
throw new ASTSemanticException();
|
||||||
|
}
|
||||||
|
else if( absDecl.getTypeSpecifier() instanceof IASTEnumerationSpecifier )
|
||||||
|
{
|
||||||
|
type.setType(TypeInfo.t_enumeration);
|
||||||
|
}
|
||||||
|
else if( absDecl.getTypeSpecifier() instanceof IASTElaboratedTypeSpecifier )
|
||||||
|
{
|
||||||
ASTClassKind kind = ((IASTElaboratedTypeSpecifier)absDecl.getTypeSpecifier()).getClassKind();
|
ASTClassKind kind = ((IASTElaboratedTypeSpecifier)absDecl.getTypeSpecifier()).getClassKind();
|
||||||
if( kind == ASTClassKind.CLASS )
|
if( kind == ASTClassKind.CLASS )
|
||||||
type = TypeInfo.t_class;
|
type.setType(TypeInfo.t_class);
|
||||||
else if( kind == ASTClassKind.STRUCT )
|
else if( kind == ASTClassKind.STRUCT )
|
||||||
type = TypeInfo.t_struct;
|
type.setType(TypeInfo.t_struct);
|
||||||
else if( kind == ASTClassKind.UNION )
|
else if( kind == ASTClassKind.UNION )
|
||||||
type = TypeInfo.t_union;
|
type.setType(TypeInfo.t_union);
|
||||||
else if( kind == ASTClassKind.ENUM )
|
else if( kind == ASTClassKind.ENUM )
|
||||||
type = TypeInfo.t_enumeration;
|
type.setType(TypeInfo.t_enumeration);
|
||||||
else
|
else
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw new ASTSemanticException();
|
throw new ASTSemanticException();
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param symbol
|
||||||
|
* @param returnType
|
||||||
|
*/
|
||||||
|
protected void setParameter(IParameterizedSymbol symbol, IASTAbstractDeclaration absDecl, boolean isParameter, List references) throws ASTSemanticException
|
||||||
|
{
|
||||||
|
if (absDecl.getTypeSpecifier() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
ISymbol paramSymbol = pst.newSymbol( "", type );
|
// now determined by another function
|
||||||
if( xrefSymbol != null )
|
TypeInfo.eType type = getParameterTypeInfo(absDecl).getType();
|
||||||
paramSymbol.setTypeSymbol( xrefSymbol );
|
|
||||||
|
|
||||||
setPointerOperators( paramSymbol, absDecl.getPointerOperators(), absDecl.getArrayModifiers() );
|
ISymbol xrefSymbol = null;
|
||||||
|
List newReferences = null;
|
||||||
|
if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
|
||||||
|
{
|
||||||
|
IASTSimpleTypeSpecifier.Type kind = ((IASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getType();
|
||||||
|
if( kind == IASTSimpleTypeSpecifier.Type.CLASS_OR_TYPENAME )
|
||||||
|
{
|
||||||
|
xrefSymbol = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getSymbol();
|
||||||
|
newReferences = ((ASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getReferences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( isParameter)
|
String paramName = "";
|
||||||
symbol.addParameter( paramSymbol );
|
if(absDecl instanceof IASTParameterDeclaration){
|
||||||
else
|
paramName = ((IASTParameterDeclaration)absDecl).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
ISymbol paramSymbol = pst.newSymbol( paramName, type );
|
||||||
|
if( xrefSymbol != null )
|
||||||
|
paramSymbol.setTypeSymbol( xrefSymbol.getTypeSymbol() );
|
||||||
|
|
||||||
|
setPointerOperators( paramSymbol, absDecl.getPointerOperators(), absDecl.getArrayModifiers() );
|
||||||
|
|
||||||
|
if( isParameter)
|
||||||
|
symbol.addParameter( paramSymbol );
|
||||||
|
else
|
||||||
symbol.setReturnType( paramSymbol );
|
symbol.setReturnType( paramSymbol );
|
||||||
|
|
||||||
if( newReferences != null )
|
if( newReferences != null )
|
||||||
references.addAll( newReferences );
|
references.addAll( newReferences );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param paramSymbol
|
* @param paramSymbol
|
||||||
|
@ -1393,11 +1430,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
}
|
}
|
||||||
else if( abstractDeclaration.getTypeSpecifier() instanceof ASTClassSpecifier )
|
else if( abstractDeclaration.getTypeSpecifier() instanceof ASTClassSpecifier )
|
||||||
{
|
{
|
||||||
symbolToBeCloned = ((ASTClassSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol();
|
symbolToBeCloned = pst.newSymbol(name, TypeInfo.t_type);
|
||||||
}
|
symbolToBeCloned.setTypeSymbol(((ASTClassSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol());
|
||||||
|
}
|
||||||
else if( abstractDeclaration.getTypeSpecifier() instanceof ASTElaboratedTypeSpecifier )
|
else if( abstractDeclaration.getTypeSpecifier() instanceof ASTElaboratedTypeSpecifier )
|
||||||
{
|
{
|
||||||
symbolToBeCloned = ((ASTElaboratedTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol();
|
symbolToBeCloned = pst.newSymbol(name, TypeInfo.t_type);
|
||||||
|
symbolToBeCloned.setTypeSymbol(((ASTElaboratedTypeSpecifier)abstractDeclaration.getTypeSpecifier()).getSymbol());
|
||||||
}
|
}
|
||||||
newSymbol = (ISymbol) symbolToBeCloned.clone();
|
newSymbol = (ISymbol) symbolToBeCloned.clone();
|
||||||
newSymbol.setName( name );
|
newSymbol.setName( name );
|
||||||
|
|
Loading…
Add table
Reference in a new issue