mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Bug 332114: Exceptions when parsing gcc-testsuite.
This commit is contained in:
parent
1fcecce140
commit
b81cf7e199
15 changed files with 122 additions and 54 deletions
|
@ -129,6 +129,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
public class AST2CPPTests extends AST2BaseTest {
|
public class AST2CPPTests extends AST2BaseTest {
|
||||||
|
@ -9289,5 +9290,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
public void testFwdLookupForDefaultArgument() throws Exception {
|
public void testFwdLookupForDefaultArgument() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// auto f2 (); // missing late return type.
|
||||||
|
public void testBug332114a() throws Exception {
|
||||||
|
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
|
||||||
|
IBinding b= bh.assertNonProblem("f2", 0);
|
||||||
|
// Must not throw a NPE
|
||||||
|
IndexCPPSignatureUtil.getSignature(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// enum E: short;
|
||||||
|
// enum E: short;
|
||||||
|
// enum E: short {e1, e2};
|
||||||
|
public void testBug332114b() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
@ -1208,7 +1208,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
||||||
ITypedef td= getBindingFromASTName("MBR_PTR", 0, ITypedef.class);
|
ITypedef td= getBindingFromASTName("MBR_PTR", 0, ITypedef.class);
|
||||||
ICPPPointerToMemberType ptrMbr= (ICPPPointerToMemberType) td.getType();
|
ICPPPointerToMemberType ptrMbr= (ICPPPointerToMemberType) td.getType();
|
||||||
IType t= ptrMbr.getMemberOfClass();
|
IType t= ptrMbr.getMemberOfClass();
|
||||||
assertInstance(t, IProblemBinding.class);
|
assertInstance(t, ISemanticProblem.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void f255(
|
// void f255(
|
||||||
|
|
|
@ -84,8 +84,16 @@ public abstract class ArithmeticConversion {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isArithmeticOrUnscopedEnum(IType op1) {
|
private boolean isArithmeticOrUnscopedEnum(IType op1) {
|
||||||
if (op1 instanceof IBasicType)
|
if (op1 instanceof IBasicType) {
|
||||||
return true;
|
final Kind kind = ((IBasicType)op1).getKind();
|
||||||
|
switch (kind) {
|
||||||
|
case eUnspecified:
|
||||||
|
case eVoid:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (op1 instanceof IEnumeration) {
|
if (op1 instanceof IEnumeration) {
|
||||||
if (op1 instanceof ICPPEnumeration && ((ICPPEnumeration) op1).isScoped())
|
if (op1 instanceof ICPPEnumeration && ((ICPPEnumeration) op1).isScoped())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class CPPASTAmbiguousParameterDeclaration extends ASTAmbiguousNode implem
|
||||||
|
|
||||||
// Setup the ast to use the alternative
|
// Setup the ast to use the alternative
|
||||||
owner.replace(this, fParameterDecl);
|
owner.replace(this, fParameterDecl);
|
||||||
|
fParameterDecl.accept(resolver);
|
||||||
|
|
||||||
IType t= CPPVisitor.createType(fParameterDecl, true);
|
IType t= CPPVisitor.createType(fParameterDecl, true);
|
||||||
if (!(t instanceof ICPPParameterPackType) ||
|
if (!(t instanceof ICPPParameterPackType) ||
|
||||||
|
|
|
@ -220,6 +220,8 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres
|
||||||
return CPPVisitor.get_type_info(this);
|
return CPPVisitor.get_type_info(this);
|
||||||
case op_bracketedPrimary:
|
case op_bracketedPrimary:
|
||||||
return getOperand().getExpressionType();
|
return getOperand().getExpressionType();
|
||||||
|
case op_throw:
|
||||||
|
return CPPSemantics.VOID_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
final IASTExpression operand = getOperand();
|
final IASTExpression operand = getOperand();
|
||||||
|
|
|
@ -80,8 +80,6 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
|
|
||||||
private class FindDefinitionAction extends ASTVisitor {
|
private class FindDefinitionAction extends ASTVisitor {
|
||||||
private char[] nameArray = CPPEnumeration.this.getNameCharArray();
|
private char[] nameArray = CPPEnumeration.this.getNameCharArray();
|
||||||
public IASTName result = null;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
shouldVisitNames = true;
|
shouldVisitNames = true;
|
||||||
shouldVisitDeclarations = true;
|
shouldVisitDeclarations = true;
|
||||||
|
@ -94,10 +92,12 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
|
if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
char[] c = name.getLookupKey();
|
char[] c = name.getLookupKey();
|
||||||
if (name.getParent() instanceof ICPPASTEnumerationSpecifier && CharArrayUtils.equals(c, nameArray)) {
|
final IASTNode parent = name.getParent();
|
||||||
|
if (parent instanceof ICPPASTEnumerationSpecifier &&
|
||||||
|
!((ICPPASTEnumerationSpecifier) parent).isOpaque() &&
|
||||||
|
CharArrayUtils.equals(c, nameArray)) {
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
if (binding == CPPEnumeration.this) {
|
if (binding == CPPEnumeration.this && getDefinition() == name) {
|
||||||
result= name;
|
|
||||||
return PROCESS_ABORT;
|
return PROCESS_ABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,12 +121,8 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTName getDefinition() {
|
public IASTName getDefinition() {
|
||||||
if (fDefinition == NOT_INITIALIZED) {
|
if (fDefinition == NOT_INITIALIZED)
|
||||||
FindDefinitionAction action = new FindDefinitionAction();
|
return null;
|
||||||
IASTNode node = CPPVisitor.getContainingBlockItem(getADeclaration()).getParent();
|
|
||||||
node.accept(action);
|
|
||||||
fDefinition = action.result;
|
|
||||||
}
|
|
||||||
return fDefinition;
|
return fDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +255,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator[] getEnumerators() {
|
public IEnumerator[] getEnumerators() {
|
||||||
|
findDefinition();
|
||||||
final IASTName definition = getDefinition();
|
final IASTName definition = getDefinition();
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
ICPPEnumeration typeInIndex= getIndexBinding();
|
ICPPEnumeration typeInIndex= getIndexBinding();
|
||||||
|
@ -291,6 +288,7 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPScope asScope() {
|
public ICPPScope asScope() {
|
||||||
|
findDefinition();
|
||||||
IASTName def = getDefinition();
|
IASTName def = getDefinition();
|
||||||
if (def == null) {
|
if (def == null) {
|
||||||
ICPPEnumeration indexBinding= getIndexBinding();
|
ICPPEnumeration indexBinding= getIndexBinding();
|
||||||
|
@ -301,4 +299,12 @@ public class CPPEnumeration extends PlatformObject implements ICPPEnumeration, I
|
||||||
}
|
}
|
||||||
return ((ICPPASTEnumerationSpecifier) def.getParent()).getScope();
|
return ((ICPPASTEnumerationSpecifier) def.getParent()).getScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void findDefinition() {
|
||||||
|
if (fDefinition == NOT_INITIALIZED) {
|
||||||
|
FindDefinitionAction action = new FindDefinitionAction();
|
||||||
|
IASTNode node = CPPVisitor.getContainingBlockItem(getADeclaration()).getParent();
|
||||||
|
node.accept(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
* Copyright (c) 2005, 2010 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
|
||||||
|
@ -58,7 +58,6 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
||||||
for (IASTName nd : nds) {
|
for (IASTName nd : nds) {
|
||||||
if (nd != null) {
|
if (nd != null) {
|
||||||
IASTNode parent = nd.getParent();
|
IASTNode parent = nd.getParent();
|
||||||
assert parent instanceof ICPPASTSimpleTypeTemplateParameter;
|
|
||||||
if (parent instanceof ICPPASTSimpleTypeTemplateParameter) {
|
if (parent instanceof ICPPASTSimpleTypeTemplateParameter) {
|
||||||
ICPPASTSimpleTypeTemplateParameter simple = (ICPPASTSimpleTypeTemplateParameter) parent;
|
ICPPASTSimpleTypeTemplateParameter simple = (ICPPASTSimpleTypeTemplateParameter) parent;
|
||||||
IASTTypeId typeId = simple.getDefaultType();
|
IASTTypeId typeId = simple.getDefaultType();
|
||||||
|
|
|
@ -2702,10 +2702,12 @@ public class CPPSemantics {
|
||||||
IASTDeclarator dtor = (IASTDeclarator) parent;
|
IASTDeclarator dtor = (IASTDeclarator) parent;
|
||||||
targetType= CPPVisitor.createType(dtor);
|
targetType= CPPVisitor.createType(dtor);
|
||||||
} else if (prop == IASTEqualsInitializer.INITIALIZER) {
|
} else if (prop == IASTEqualsInitializer.INITIALIZER) {
|
||||||
IASTEqualsInitializer initExp = (IASTEqualsInitializer) parent;
|
final IASTNode grandpa = parent.getParent();
|
||||||
if (initExp.getParent() instanceof IASTDeclarator) {
|
if (grandpa instanceof IASTDeclarator) {
|
||||||
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
|
IASTDeclarator dtor = ASTQueries.findInnermostDeclarator((IASTDeclarator) grandpa);
|
||||||
targetType= CPPVisitor.createType(dtor);
|
IBinding var= dtor.getName().resolvePreBinding();
|
||||||
|
if (var instanceof IVariable)
|
||||||
|
targetType= ((IVariable) var).getType();
|
||||||
}
|
}
|
||||||
} else if (prop == ICPPASTConstructorInitializer.ARGUMENT) {
|
} else if (prop == ICPPASTConstructorInitializer.ARGUMENT) {
|
||||||
ICPPASTConstructorInitializer init = (ICPPASTConstructorInitializer) parent;
|
ICPPASTConstructorInitializer init = (ICPPASTConstructorInitializer) parent;
|
||||||
|
|
|
@ -921,6 +921,7 @@ public class CPPTemplates {
|
||||||
public static IType[] instantiateTypes(IType[] types, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within) {
|
public static IType[] instantiateTypes(IType[] types, ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within) {
|
||||||
// Don't create a new array until it's really needed.
|
// Don't create a new array until it's really needed.
|
||||||
IType[] result = types;
|
IType[] result = types;
|
||||||
|
int j= 0;
|
||||||
for (int i = 0; i < types.length; i++) {
|
for (int i = 0; i < types.length; i++) {
|
||||||
IType origType = types[i];
|
IType origType = types[i];
|
||||||
IType newType;
|
IType newType;
|
||||||
|
@ -932,25 +933,24 @@ public class CPPTemplates {
|
||||||
} else if (packSize == PACK_SIZE_DEFER) {
|
} else if (packSize == PACK_SIZE_DEFER) {
|
||||||
newType= origType;
|
newType= origType;
|
||||||
} else {
|
} else {
|
||||||
IType[] packResult= new IType[types.length+packSize-1];
|
IType[] newResult= new IType[result.length+packSize-1];
|
||||||
System.arraycopy(result, 0, packResult, 0, types.length-1);
|
System.arraycopy(result, 0, newResult, 0, j);
|
||||||
for(int j=0; j<packSize; j++) {
|
result= newResult;
|
||||||
packResult[i+j]= CPPTemplates.instantiateType(origType, tpMap, j, within);
|
for(int k=0; k<packSize; k++) {
|
||||||
|
result[j++]= CPPTemplates.instantiateType(origType, tpMap, k, within);
|
||||||
}
|
}
|
||||||
result= packResult;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within);
|
newType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within);
|
||||||
}
|
}
|
||||||
if (result != types) {
|
if (result != types) {
|
||||||
result[i]= newType;
|
result[j++]= newType;
|
||||||
} else if (newType != origType) {
|
} else if (newType != origType) {
|
||||||
result = new IType[types.length];
|
result = new IType[types.length];
|
||||||
if (i > 0) {
|
j= i;
|
||||||
System.arraycopy(types, 0, result, 0, i);
|
System.arraycopy(types, 0, result, 0, i);
|
||||||
}
|
result[j++]= newType;
|
||||||
result[i]= newType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -345,9 +345,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
IType ft2= e.getFixedType();
|
IType ft2= e.getFixedType();
|
||||||
if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) {
|
if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) {
|
||||||
if (specifier.isOpaque()) {
|
if (specifier.isOpaque()) {
|
||||||
e.addDeclaration(specifier);
|
e.addDeclaration(name);
|
||||||
} else if (e.getDefinition() == null) {
|
} else if (e.getDefinition() == null) {
|
||||||
e.addDefinition(specifier);
|
e.addDefinition(name);
|
||||||
} else {
|
} else {
|
||||||
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
|
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
|
||||||
}
|
}
|
||||||
|
@ -1752,10 +1752,12 @@ public class CPPVisitor extends ASTQueries {
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
if (parent instanceof ICPPASTNewExpression) {
|
if (parent instanceof ICPPASTNewExpression) {
|
||||||
IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer();
|
IASTInitializer initializer = ((ICPPASTNewExpression) parent).getInitializer();
|
||||||
IASTInitializerClause[] arguments = ((ICPPASTConstructorInitializer) initializer).getArguments();
|
if (initializer != null) {
|
||||||
if (arguments.length == 1) {
|
IASTInitializerClause[] arguments = ((ICPPASTConstructorInitializer) initializer).getArguments();
|
||||||
initClause = arguments[0];
|
if (arguments.length == 1) {
|
||||||
}
|
initClause = arguments[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (parent instanceof IASTCompositeTypeSpecifier &&
|
} else if (parent instanceof IASTCompositeTypeSpecifier &&
|
||||||
declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) {
|
declSpec.getStorageClass() != IASTDeclSpecifier.sc_static) {
|
||||||
// Non-static auto-typed class members are not allowed.
|
// Non-static auto-typed class members are not allowed.
|
||||||
|
|
|
@ -16,6 +16,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.*;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CVQualifier.*;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
@ -540,10 +543,10 @@ public class SemanticUtil {
|
||||||
* no inheritance relation
|
* no inheritance relation
|
||||||
*/
|
*/
|
||||||
public static final int calculateInheritanceDepth(IType type, IType baseClass) {
|
public static final int calculateInheritanceDepth(IType type, IType baseClass) {
|
||||||
return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, type, baseClass);
|
return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>(), type, baseClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int calculateInheritanceDepth(int maxdepth, IType type, IType baseClass) {
|
private static final int calculateInheritanceDepth(int maxdepth, Set<Object> hashSet, IType type, IType baseClass) {
|
||||||
if (type == baseClass || type.isSameType(baseClass)) {
|
if (type == baseClass || type.isSameType(baseClass)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -556,7 +559,7 @@ public class SemanticUtil {
|
||||||
|
|
||||||
for (ICPPBase cppBase : clazz.getBases()) {
|
for (ICPPBase cppBase : clazz.getBases()) {
|
||||||
IBinding base= cppBase.getBaseClass();
|
IBinding base= cppBase.getBaseClass();
|
||||||
if (base instanceof IType) {
|
if (base instanceof IType && hashSet.add(base)) {
|
||||||
IType tbase= (IType) base;
|
IType tbase= (IType) base;
|
||||||
if (tbase.isSameType(baseClass) ||
|
if (tbase.isSameType(baseClass) ||
|
||||||
(baseClass instanceof ICPPSpecialization && // allow some flexibility with templates
|
(baseClass instanceof ICPPSpecialization && // allow some flexibility with templates
|
||||||
|
@ -565,7 +568,7 @@ public class SemanticUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tbase instanceof ICPPClassType) {
|
if (tbase instanceof ICPPClassType) {
|
||||||
int n= calculateInheritanceDepth(maxdepth - 1, tbase, baseClass);
|
int n= calculateInheritanceDepth(maxdepth - 1, hashSet, tbase, baseClass);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
return n + 1;
|
return n + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,12 @@ package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
|
@ -30,6 +32,9 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
||||||
public final static byte NULL_TYPE= 0;
|
public final static byte NULL_TYPE= 0;
|
||||||
public final static byte INDIRECT_TYPE= (byte) -1;
|
public final static byte INDIRECT_TYPE= (byte) -1;
|
||||||
public final static byte BINDING_TYPE= (byte) -2;
|
public final static byte BINDING_TYPE= (byte) -2;
|
||||||
|
public final static byte UNSTORABLE_TYPE= (byte) -3;
|
||||||
|
|
||||||
|
public final static IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
assert EMPTY.length == Database.TYPE_SIZE;
|
assert EMPTY.length == Database.TYPE_SIZE;
|
||||||
|
@ -65,10 +70,12 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
||||||
public void marshalBinding(IBinding binding) throws CoreException {
|
public void marshalBinding(IBinding binding) throws CoreException {
|
||||||
if (binding instanceof ISerializableType) {
|
if (binding instanceof ISerializableType) {
|
||||||
((ISerializableType) binding).marshal(this);
|
((ISerializableType) binding).marshal(this);
|
||||||
|
} else if (binding == null) {
|
||||||
|
putByte(NULL_TYPE);
|
||||||
} else {
|
} else {
|
||||||
PDOMBinding pb= fLinkage.addTypeBinding(binding);
|
PDOMBinding pb= fLinkage.addTypeBinding(binding);
|
||||||
if (pb == null) {
|
if (pb == null) {
|
||||||
putByte(NULL_TYPE);
|
putByte(UNSTORABLE_TYPE);
|
||||||
} else {
|
} else {
|
||||||
putByte(BINDING_TYPE);
|
putByte(BINDING_TYPE);
|
||||||
putByte((byte) 0);
|
putByte((byte) 0);
|
||||||
|
@ -86,10 +93,10 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
||||||
fPos+= 2;
|
fPos+= 2;
|
||||||
long rec= getRecordPointer();
|
long rec= getRecordPointer();
|
||||||
return (IBinding) fLinkage.getNode(rec);
|
return (IBinding) fLinkage.getNode(rec);
|
||||||
} else if (firstByte == 0) {
|
} else if (firstByte == NULL_TYPE || firstByte == UNSTORABLE_TYPE) {
|
||||||
fPos++;
|
fPos++;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IType type= fLinkage.unmarshalType(this);
|
IType type= fLinkage.unmarshalType(this);
|
||||||
if (type == null || type instanceof IBinding)
|
if (type == null || type instanceof IBinding)
|
||||||
|
@ -103,9 +110,11 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
||||||
marshalBinding((IBinding) type);
|
marshalBinding((IBinding) type);
|
||||||
} else if (type instanceof ISerializableType) {
|
} else if (type instanceof ISerializableType) {
|
||||||
((ISerializableType) type).marshal(this);
|
((ISerializableType) type).marshal(this);
|
||||||
} else {
|
} else if (type == null) {
|
||||||
assert type == null : "Cannot serialize " + ASTTypeUtil.getType(type) + "(" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
|
||||||
putByte(NULL_TYPE);
|
putByte(NULL_TYPE);
|
||||||
|
} else {
|
||||||
|
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + "(" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
|
||||||
|
putByte(UNSTORABLE_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,9 +127,12 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer {
|
||||||
fPos+= 2;
|
fPos+= 2;
|
||||||
long rec= getRecordPointer();
|
long rec= getRecordPointer();
|
||||||
return (IType) fLinkage.getNode(rec);
|
return (IType) fLinkage.getNode(rec);
|
||||||
} else if (firstByte == 0) {
|
} else if (firstByte == NULL_TYPE) {
|
||||||
fPos++;
|
fPos++;
|
||||||
return null;
|
return null;
|
||||||
|
} else if (firstByte == UNSTORABLE_TYPE) {
|
||||||
|
fPos++;
|
||||||
|
return UNSTORABLE_TYPE_PROBLEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fLinkage.unmarshalType(this);
|
return fLinkage.unmarshalType(this);
|
||||||
|
|
|
@ -476,6 +476,8 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
data= new byte[len];
|
data= new byte[len];
|
||||||
db.getBytes(ptr+2, data);
|
db.getBytes(ptr+2, data);
|
||||||
break;
|
break;
|
||||||
|
case TypeMarshalBuffer.UNSTORABLE_TYPE:
|
||||||
|
return TypeMarshalBuffer.UNSTORABLE_TYPE_PROBLEM;
|
||||||
case TypeMarshalBuffer.NULL_TYPE:
|
case TypeMarshalBuffer.NULL_TYPE:
|
||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -127,14 +127,22 @@ final class PDOMCParameter extends PDOMNamedNode implements IParameter, IPDOMBin
|
||||||
return getNodeType();
|
return getNodeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(PDOMLinkage linkage) throws CoreException {
|
public void delete(PDOMLinkage linkage) throws CoreException {
|
||||||
long rec = getNextPtr();
|
PDOMCParameter p= this;
|
||||||
if (rec != 0) {
|
for (;;) {
|
||||||
new PDOMCParameter(linkage, rec, null).delete(linkage);
|
long rec = p.getNextPtr();
|
||||||
|
p.flatDelete(linkage);
|
||||||
|
if (rec == 0)
|
||||||
|
return;
|
||||||
|
p= new PDOMCParameter(linkage, rec, null);
|
||||||
}
|
}
|
||||||
super.delete(linkage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void flatDelete(PDOMLinkage linkage) throws CoreException {
|
||||||
|
super.delete(linkage);
|
||||||
|
}
|
||||||
|
|
||||||
public long getNextPtr() throws CoreException {
|
public long getNextPtr() throws CoreException {
|
||||||
long rec = getDB().getRecPtr(record + NEXT_PARAM);
|
long rec = getDB().getRecPtr(record + NEXT_PARAM);
|
||||||
|
|
|
@ -204,10 +204,17 @@ class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter, IPDOMBind
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(PDOMLinkage linkage) throws CoreException {
|
public void delete(PDOMLinkage linkage) throws CoreException {
|
||||||
long rec = getNextPtr();
|
PDOMCPPParameter p= this;
|
||||||
if (rec != 0) {
|
for (;;) {
|
||||||
new PDOMCPPParameter(linkage, rec, null).delete(linkage);
|
long rec = p.getNextPtr();
|
||||||
|
p.flatDelete(linkage);
|
||||||
|
if (rec == 0)
|
||||||
|
return;
|
||||||
|
p= new PDOMCPPParameter(linkage, rec, null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void flatDelete(PDOMLinkage linkage) throws CoreException {
|
||||||
super.delete(linkage);
|
super.delete(linkage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue