1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-30 20:35:38 +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 ){
IASTNode def = function.getDefinition();
while (def instanceof IASTName) {
def = def.getParent();
}
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) def;
ICPPASTFunctionDeclarator[] ds = (ICPPASTFunctionDeclarator[]) function.getDeclarations();
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) function.getDefinition();
IASTNode[] ds = (IASTNode[]) function.getDeclarations();
int i = -1;
do{
if( dtor != null ){
@ -517,8 +514,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
if( declSpec.getStorageClass() == storage )
return true;
}
if( ds != null && ++i < ds.length )
dtor = ds[i];
if( ds != null && ++i < ds.length ) {
dtor = (ICPPASTFunctionDeclarator) ds[i];
}
else
break;
} while( dtor != null );

View file

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

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
* Bryan Wilkinson (QNX)
*******************************************************************************/
/*
* Created on Mar 11, 2005
@ -347,9 +348,7 @@ public class CPPTemplates {
for (int i = 0; i < templateParams.length; i++) {
argMap.put( templateParams[i], args[i] );
}
if( template instanceof ICPPInternalTemplate ){
spec = ((ICPPInternalTemplate)template).getInstance( args );
}
spec = ((ICPPInternalTemplateInstantiator)template).getInstance( args );
if( spec == null ) {
ICPPScope scope = (ICPPScope) CPPVisitor.getContainingScope( id );
spec = new CPPClassSpecialization(binding, scope, argMap );
@ -357,13 +356,15 @@ public class CPPTemplates {
((ICPPInternalTemplate)template).addSpecialization( args, (ICPPSpecialization) spec );
}
}
IASTNode parent = id.getParent();
while( !(parent instanceof IASTDeclSpecifier ) )
parent = parent.getParent();
if( parent instanceof IASTElaboratedTypeSpecifier )
((ICPPInternalBinding)spec).addDeclaration( id );
else if( parent instanceof IASTCompositeTypeSpecifier )
((ICPPInternalBinding)spec).addDefinition( id );
if (spec instanceof ICPPInternalBinding) {
IASTNode parent = id.getParent();
while( !(parent instanceof IASTDeclSpecifier ) )
parent = parent.getParent();
if( parent instanceof IASTElaboratedTypeSpecifier )
((ICPPInternalBinding)spec).addDeclaration( id );
else if( parent instanceof IASTCompositeTypeSpecifier )
((ICPPInternalBinding)spec).addDefinition( id );
}
return spec;
}
//else partial specialization
@ -1438,7 +1439,7 @@ public class CPPTemplates {
return null;
}
IType paramType = (IType) ((ICPPInternalTemplate)template).instantiate( args );
IType paramType = (IType) ((ICPPInternalTemplateInstantiator)template).instantiate( args );
IParameter [] functionParameters = new IParameter[] { new CPPParameter( paramType ) };
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
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -2061,7 +2061,7 @@ public class CPPVisitor {
}
public static char [][] getQualifiedNameCharArray( IBinding binding ) {
IASTName [] ns = null;
IName [] ns = null;
try {
ICPPScope scope = (ICPPScope) binding.getScope();
while( scope != null ){
@ -2078,12 +2078,12 @@ public class CPPVisitor {
if( scope instanceof ICPPNamespaceScope && scope.getScopeName().toCharArray().length == 0 )
break;
ns = (IASTName[]) ArrayUtil.append( IASTName.class, ns, n );
ns = (IName[]) ArrayUtil.append( IName.class, ns, n );
scope = (ICPPScope) scope.getParent();
}
} catch ( DOMException e ) {
}
ns = (IASTName[]) ArrayUtil.trim( IASTName.class, ns );
ns = (IName[]) ArrayUtil.trim( IName.class, ns );
char[] [] result = new char[ ns.length + 1 ][];
for( int i = ns.length - 1; i >= 0; i-- ){
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.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
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.ICPPInternalFunction;
import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -137,7 +138,9 @@ class PDOMCPPLinkage extends PDOMLinkage {
try {
ICPPTemplateParameter[] params = binding.getTemplateParameters();
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 (DOMException e) {
@ -273,6 +276,7 @@ class PDOMCPPLinkage extends PDOMLinkage {
if (binding instanceof ICPPSpecialization) {
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
if (specialized == null || specialized instanceof ProblemBinding) return null;
PDOMBinding pdomSpecialized = addBinding(specialized);
if (pdomSpecialized == null) return null;