1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 21:05:37 +02:00

Patch for Bryan - 181015 - Fix a few exceptions in the indexer.

This commit is contained in:
Doug Schaefer 2007-04-09 16:13:06 +00:00
parent b09b4cbbeb
commit 942c2996fa
5 changed files with 29 additions and 26 deletions

View file

@ -496,12 +496,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
} }
static public boolean hasStorageClass( ICPPInternalFunction function, int storage ){ static public boolean hasStorageClass( ICPPInternalFunction function, int storage ){
IASTNode def = function.getDefinition(); ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) function.getDefinition();
while (def instanceof IASTName) { IASTNode[] ds = (IASTNode[]) function.getDeclarations();
def = def.getParent();
}
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) def;
ICPPASTFunctionDeclarator[] ds = (ICPPASTFunctionDeclarator[]) function.getDeclarations();
int i = -1; int i = -1;
do{ do{
if( dtor != null ){ if( dtor != null ){
@ -517,8 +514,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
if( declSpec.getStorageClass() == storage ) if( declSpec.getStorageClass() == storage )
return true; return true;
} }
if( ds != null && ++i < ds.length ) if( ds != null && ++i < ds.length ) {
dtor = ds[i]; dtor = (ICPPASTFunctionDeclarator) ds[i];
}
else else
break; break;
} while( dtor != null ); } while( dtor != null );

View file

@ -187,7 +187,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
if( !(n instanceof ICPPASTFunctionDeclarator) ) if( !(n instanceof ICPPASTFunctionDeclarator) )
return; return;
updateParameterBindings( (ICPPASTFunctionDeclarator) n ); updateParameterBindings( (ICPPASTFunctionDeclarator) n );
super.addDefinition( node ); super.addDefinition( n );
} }
public void addDeclaration(IASTNode node) { public void addDeclaration(IASTNode node) {
IASTNode n = node; IASTNode n = node;
@ -196,7 +196,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
if( !(n instanceof ICPPASTFunctionDeclarator) ) if( !(n instanceof ICPPASTFunctionDeclarator) )
return; return;
updateParameterBindings( (ICPPASTFunctionDeclarator) n ); updateParameterBindings( (ICPPASTFunctionDeclarator) n );
super.addDeclaration( node ); super.addDeclaration( n );
} }
protected void updateParameterBindings( ICPPASTFunctionDeclarator fdtor ){ protected void updateParameterBindings( ICPPASTFunctionDeclarator fdtor ){
IParameter [] params = null; IParameter [] params = null;

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Bryan Wilkinson (QNX)
*******************************************************************************/ *******************************************************************************/
/* /*
* Created on Mar 11, 2005 * Created on Mar 11, 2005
@ -347,9 +348,7 @@ public class CPPTemplates {
for (int i = 0; i < templateParams.length; i++) { for (int i = 0; i < templateParams.length; i++) {
argMap.put( templateParams[i], args[i] ); argMap.put( templateParams[i], args[i] );
} }
if( template instanceof ICPPInternalTemplate ){ spec = ((ICPPInternalTemplateInstantiator)template).getInstance( args );
spec = ((ICPPInternalTemplate)template).getInstance( args );
}
if( spec == null ) { if( spec == null ) {
ICPPScope scope = (ICPPScope) CPPVisitor.getContainingScope( id ); ICPPScope scope = (ICPPScope) CPPVisitor.getContainingScope( id );
spec = new CPPClassSpecialization(binding, scope, argMap ); spec = new CPPClassSpecialization(binding, scope, argMap );
@ -357,13 +356,15 @@ public class CPPTemplates {
((ICPPInternalTemplate)template).addSpecialization( args, (ICPPSpecialization) spec ); ((ICPPInternalTemplate)template).addSpecialization( args, (ICPPSpecialization) spec );
} }
} }
IASTNode parent = id.getParent(); if (spec instanceof ICPPInternalBinding) {
while( !(parent instanceof IASTDeclSpecifier ) ) IASTNode parent = id.getParent();
parent = parent.getParent(); while( !(parent instanceof IASTDeclSpecifier ) )
if( parent instanceof IASTElaboratedTypeSpecifier ) parent = parent.getParent();
((ICPPInternalBinding)spec).addDeclaration( id ); if( parent instanceof IASTElaboratedTypeSpecifier )
else if( parent instanceof IASTCompositeTypeSpecifier ) ((ICPPInternalBinding)spec).addDeclaration( id );
((ICPPInternalBinding)spec).addDefinition( id ); else if( parent instanceof IASTCompositeTypeSpecifier )
((ICPPInternalBinding)spec).addDefinition( id );
}
return spec; return spec;
} }
//else partial specialization //else partial specialization
@ -1438,7 +1439,7 @@ public class CPPTemplates {
return null; return null;
} }
IType paramType = (IType) ((ICPPInternalTemplate)template).instantiate( args ); IType paramType = (IType) ((ICPPInternalTemplateInstantiator)template).instantiate( args );
IParameter [] functionParameters = new IParameter[] { new CPPParameter( paramType ) }; IParameter [] functionParameters = new IParameter[] { new CPPParameter( paramType ) };
try { try {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006, 2007 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -2061,7 +2061,7 @@ public class CPPVisitor {
} }
public static char [][] getQualifiedNameCharArray( IBinding binding ) { public static char [][] getQualifiedNameCharArray( IBinding binding ) {
IASTName [] ns = null; IName [] ns = null;
try { try {
ICPPScope scope = (ICPPScope) binding.getScope(); ICPPScope scope = (ICPPScope) binding.getScope();
while( scope != null ){ while( scope != null ){
@ -2078,12 +2078,12 @@ public class CPPVisitor {
if( scope instanceof ICPPNamespaceScope && scope.getScopeName().toCharArray().length == 0 ) if( scope instanceof ICPPNamespaceScope && scope.getScopeName().toCharArray().length == 0 )
break; break;
ns = (IASTName[]) ArrayUtil.append( IASTName.class, ns, n ); ns = (IName[]) ArrayUtil.append( IName.class, ns, n );
scope = (ICPPScope) scope.getParent(); scope = (ICPPScope) scope.getParent();
} }
} catch ( DOMException e ) { } catch ( DOMException e ) {
} }
ns = (IASTName[]) ArrayUtil.trim( IASTName.class, ns ); ns = (IName[]) ArrayUtil.trim( IName.class, ns );
char[] [] result = new char[ ns.length + 1 ][]; char[] [] result = new char[ ns.length + 1 ][];
for( int i = ns.length - 1; i >= 0; i-- ){ for( int i = ns.length - 1; i >= 0; i-- ){
result[ ns.length - i - 1 ] = ns[i].toCharArray(); result[ ns.length - i - 1 ] = ns[i].toCharArray();

View file

@ -54,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -137,7 +138,9 @@ class PDOMCPPLinkage extends PDOMLinkage {
try { try {
ICPPTemplateParameter[] params = binding.getTemplateParameters(); ICPPTemplateParameter[] params = binding.getTemplateParameters();
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {
addBinding(params[i]); if (params[i] != null && !(params[i] instanceof ProblemBinding)) {
addBinding(params[i]);
}
} }
} catch (CoreException e) { } catch (CoreException e) {
} catch (DOMException e) { } catch (DOMException e) {
@ -273,6 +276,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
if (binding instanceof ICPPSpecialization) { if (binding instanceof ICPPSpecialization) {
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding(); IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
if (specialized == null || specialized instanceof ProblemBinding) return null;
PDOMBinding pdomSpecialized = addBinding(specialized); PDOMBinding pdomSpecialized = addBinding(specialized);
if (pdomSpecialized == null) return null; if (pdomSpecialized == null) return null;