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

Fixes an ArrayOutOfBoundsException, bug 219773.

This commit is contained in:
Markus Schorn 2008-03-11 08:28:48 +00:00
parent 319b6d514f
commit a3d89182db

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@ -61,6 +62,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
/** /**
* The size in bytes of a PDOMCPPFunction record in the database. * The size in bytes of a PDOMCPPFunction record in the database.
*/ */
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 13; protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 13;
public PDOMCPPFunctionSpecialization(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding specialized) throws CoreException { public PDOMCPPFunctionSpecialization(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding specialized) throws CoreException {
@ -82,13 +84,14 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
ft= getType(); ft= getType();
IParameter[] params= function.getParameters(); IParameter[] params= function.getParameters();
IType[] paramTypes= ft.getParameterTypes(); IType[] paramTypes= ft.getParameterTypes();
db.putInt(record + NUM_PARAMS, params.length);
ICPPFunction sFunc= (ICPPFunction) ((ICPPSpecialization)function).getSpecializedBinding(); ICPPFunction sFunc= (ICPPFunction) ((ICPPSpecialization)function).getSpecializedBinding();
IParameter[] sParams= sFunc.getParameters(); IParameter[] sParams= sFunc.getParameters();
IType[] sParamTypes= sFunc.getType().getParameterTypes(); IType[] sParamTypes= sFunc.getType().getParameterTypes();
for (int i=0; i<params.length; ++i) { final int length= Math.min(sParamTypes.length, params.length);
db.putInt(record + NUM_PARAMS, length);
for (int i=0; i<length; ++i) {
int typeRecord= i<paramTypes.length && paramTypes[i]!=null ? ((PDOMNode)paramTypes[i]).getRecord() : 0; int typeRecord= i<paramTypes.length && paramTypes[i]!=null ? ((PDOMNode)paramTypes[i]).getRecord() : 0;
//TODO shouldn't need to make new parameter (find old one) //TODO shouldn't need to make new parameter (find old one)
PDOMCPPParameter sParam = new PDOMCPPParameter(pdom, this, sParams[i], sParamTypes[i]); PDOMCPPParameter sParam = new PDOMCPPParameter(pdom, this, sParams[i], sParamTypes[i]);
@ -104,12 +107,14 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
super(pdom, bindingRecord); super(pdom, bindingRecord);
} }
@Override
protected int getRecordSize() { protected int getRecordSize() {
return RECORD_SIZE; return RECORD_SIZE;
} }
@Override
public int getNodeType() { public int getNodeType() {
return PDOMCPPLinkage.CPP_FUNCTION_SPECIALIZATION; return IIndexCPPBindingConstants.CPP_FUNCTION_SPECIALIZATION;
} }
public PDOMCPPParameterSpecialization getFirstParameter() throws CoreException { public PDOMCPPParameterSpecialization getFirstParameter() throws CoreException {
@ -200,6 +205,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
return false; return false;
} }
@Override
public int pdomCompareTo(PDOMBinding other) { public int pdomCompareTo(PDOMBinding other) {
int cmp= super.pdomCompareTo(other); int cmp= super.pdomCompareTo(other);
return cmp==0 ? PDOMCPPFunction.compareSignatures(this, other) : cmp; return cmp==0 ? PDOMCPPFunction.compareSignatures(this, other) : cmp;