1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed infinite loop in indexer that happened when CPPTypedefSpecialization.getType method returned the same object as this. This problematic behavior was triggered by a template argument containing a wrapped ProblemBinding.

This commit is contained in:
Sergey Prigogin 2008-05-25 23:11:38 +00:00
parent 4116aadcb0
commit c3a011ab81
3 changed files with 32 additions and 28 deletions

View file

@ -663,8 +663,7 @@ public class CPPSemantics {
// now scope is fully cached.
final IBinding[] bindings = scope.getBindings(data.astName, true, data.prefixLookup, fileSet);
mergeResults(data, bindings, true);
}
else {
} else {
boolean done= false;
if (!ASTInternal.isFullyCached(scope)) {
final IASTName[] names= lookupInScope(data, scope, blockItem);

View file

@ -1636,8 +1636,14 @@ public class CPPTemplates {
}
static private boolean isValidArgument(ICPPTemplateParameter param, IType argument) {
//TODO
return true;
try {
while (argument instanceof ITypeContainer) {
argument = ((ITypeContainer) argument).getType();
}
} catch (DOMException e) {
return false;
}
return !(argument instanceof IProblemBinding);
}
static protected boolean matchTemplateParameterAndArgument(ICPPTemplateParameter param, IType argument, ObjectMap map) {
@ -1658,7 +1664,6 @@ public class CPPTemplates {
return false;
}
int size = pParams.length;
if (aParams.length != size) {
return false;
@ -1667,8 +1672,7 @@ public class CPPTemplates {
for (int i = 0; i < size; i++) {
if ((pParams[i] instanceof ICPPTemplateTypeParameter && !(aParams[i] instanceof ICPPTemplateTypeParameter)) ||
(pParams[i] instanceof ICPPTemplateTemplateParameter && !(aParams[i] instanceof ICPPTemplateTemplateParameter)) ||
(pParams[i] instanceof ICPPTemplateNonTypeParameter && !(aParams[i] instanceof ICPPTemplateNonTypeParameter)))
{
(pParams[i] instanceof ICPPTemplateNonTypeParameter && !(aParams[i] instanceof ICPPTemplateNonTypeParameter))) {
return false;
}
}

View file

@ -1245,8 +1245,7 @@ public class CPPVisitor {
} else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
IASTNode p = name.getParent().getParent();
if (p instanceof IASTSimpleDeclaration &&
((IASTSimpleDeclaration)p).getDeclarators().length == 0)
{
((IASTSimpleDeclaration) p).getDeclarators().length == 0) {
break;
}
} else if (prop == IASTDeclarator.DECLARATOR_NAME) {
@ -1608,17 +1607,18 @@ public class CPPVisitor {
private static IType getPointerTypes(IType type, IASTDeclarator declarator) {
IASTPointerOperator[] ptrOps = declarator.getPointerOperators();
for (IASTPointerOperator ptrOp : ptrOps) {
if (ptrOp instanceof IGPPASTPointerToMember)
if (ptrOp instanceof IGPPASTPointerToMember) {
type = new GPPPointerToMemberType(type, (IGPPASTPointerToMember) ptrOp);
else if (ptrOp instanceof ICPPASTPointerToMember)
} else if (ptrOp instanceof ICPPASTPointerToMember) {
type = new CPPPointerToMemberType(type, (ICPPASTPointerToMember) ptrOp);
else if (ptrOp instanceof IGPPASTPointer)
} else if (ptrOp instanceof IGPPASTPointer) {
type = new GPPPointerType(type, (IGPPASTPointer) ptrOp);
else if (ptrOp instanceof IASTPointer)
} else if (ptrOp instanceof IASTPointer) {
type = new CPPPointerType(type, (IASTPointer) ptrOp);
else if (ptrOp instanceof ICPPASTReferenceOperator)
} else if (ptrOp instanceof ICPPASTReferenceOperator) {
type = new CPPReferenceType(type);
}
}
return type;
}
@ -1651,14 +1651,15 @@ public class CPPVisitor {
node = node.getParent();
}
if (node instanceof IASTParameterDeclaration)
if (node instanceof IASTParameterDeclaration) {
declSpec = ((IASTParameterDeclaration) node).getDeclSpecifier();
else if (node instanceof IASTSimpleDeclaration)
} else if (node instanceof IASTSimpleDeclaration) {
declSpec = ((IASTSimpleDeclaration)node).getDeclSpecifier();
else if (node instanceof IASTFunctionDefinition)
} else if (node instanceof IASTFunctionDefinition) {
declSpec = ((IASTFunctionDefinition)node).getDeclSpecifier();
else if (node instanceof IASTTypeId)
} else if (node instanceof IASTTypeId) {
declSpec = ((IASTTypeId)node).getDeclSpecifier();
}
IType type = createType(declSpec);
type = createType(type, declarator);
@ -1965,7 +1966,7 @@ public class CPPVisitor {
IType type = getExpressionType(((IASTUnaryExpression)expression).getOperand());
while (type instanceof ITypedef) {
try {
type = ((ITypeContainer)type).getType();
type = ((ITypedef) type).getType();
} catch (DOMException e) {
break;
}