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

Fix for 107821, StackOverflowError during indexing.

This commit is contained in:
Markus Schorn 2007-06-19 07:19:51 +00:00
parent c1eac4b95e
commit f0b4d7ac80

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
@ -40,7 +41,6 @@ import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexLinkage; import org.eclipse.cdt.core.index.IIndexLinkage;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecializationScope;
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.composite.CompositeScope; import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
@ -193,12 +193,12 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
* @throws CoreException * @throws CoreException
*/ */
protected PDOMNode getAdaptedParent(IBinding binding, boolean createFileLocalScope, boolean addParent) throws CoreException { protected PDOMNode getAdaptedParent(IBinding binding, boolean createFileLocalScope, boolean addParent) throws CoreException {
try {
IBinding scopeBinding = null; IBinding scopeBinding = null;
if (binding instanceof ICPPTemplateInstance) { if (binding instanceof ICPPTemplateInstance) {
scopeBinding = ((ICPPTemplateInstance)binding).getTemplateDefinition(); scopeBinding = ((ICPPTemplateInstance)binding).getTemplateDefinition();
} else { }
try { else {
IScope scope = binding.getScope(); IScope scope = binding.getScope();
if (scope == null) { if (scope == null) {
if (binding instanceof ICPPDeferredTemplateInstance) { if (binding instanceof ICPPDeferredTemplateInstance) {
@ -239,6 +239,9 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
// the scope is from the ast // the scope is from the ast
if (scope instanceof ICPPTemplateScope && !(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) { if (scope instanceof ICPPTemplateScope && !(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) {
scope = scope.getParent(); scope = scope.getParent();
if (scope == null) {
return null;
}
} }
if (scope instanceof ICPPNamespaceScope) { if (scope instanceof ICPPNamespaceScope) {
@ -250,8 +253,9 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
} }
IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope); IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
if (scopeNode instanceof IASTCompoundStatement) if (scopeNode instanceof IASTCompoundStatement) {
return null; return null;
}
else if (scopeNode instanceof IASTTranslationUnit) { else if (scopeNode instanceof IASTTranslationUnit) {
if (isFileLocalBinding(binding)) { if (isFileLocalBinding(binding)) {
IASTTranslationUnit tu= (IASTTranslationUnit) scopeNode; IASTTranslationUnit tu= (IASTTranslationUnit) scopeNode;
@ -260,21 +264,18 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
return this; return this;
} }
else { else {
if (scope instanceof CPPClassSpecializationScope) { if (scope instanceof ICPPClassScope) {
scopeBinding = ((CPPClassSpecializationScope)scope).getClassType(); scopeBinding = ((ICPPClassScope)scope).getClassType();
} else { }
else {
IName scopeName = scope.getScopeName(); IName scopeName = scope.getScopeName();
if (scopeName instanceof IASTName) { if (scopeName instanceof IASTName) {
scopeBinding = ((IASTName) scopeName).resolveBinding(); scopeBinding = ((IASTName) scopeName).resolveBinding();
} }
} }
} }
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
} }
} if (scopeBinding != null && scopeBinding != binding) {
if (scopeBinding != null) {
PDOMBinding scopePDOMBinding = null; PDOMBinding scopePDOMBinding = null;
if (addParent) { if (addParent) {
scopePDOMBinding = addBinding(scopeBinding); scopePDOMBinding = addBinding(scopeBinding);
@ -284,6 +285,10 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
if (scopePDOMBinding != null) if (scopePDOMBinding != null)
return scopePDOMBinding; return scopePDOMBinding;
} }
}
catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
return null; return null;
} }