mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 312423: Replace null-types with problem types.
This commit is contained in:
parent
9ed8866605
commit
7f684f342a
9 changed files with 28 additions and 25 deletions
|
@ -42,7 +42,6 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CASTTypeId;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
@ -246,9 +245,6 @@ public class ASTTypeUtil {
|
|||
result.append(Keywords.cpRBRACKET);
|
||||
} else if (type instanceof IBasicType) {
|
||||
IBasicType basicType= (IBasicType) type;
|
||||
if (basicType.getModifiers() == CPPBasicType.UNIQUE_TYPE_QUALIFIER) {
|
||||
return "@" + String.valueOf(basicType.hashCode()); //$NON-NLS-1$
|
||||
}
|
||||
final Kind kind = basicType.getKind();
|
||||
if (basicType.isSigned()) {
|
||||
// 3.9.1.2: signed integer types
|
||||
|
|
|
@ -23,7 +23,8 @@ public interface ISemanticProblem {
|
|||
int TYPE_UNRESOLVED_NAME = 10001;
|
||||
int TYPE_AUTO_FOR_NON_STATIC_FIELD = 10002;
|
||||
int TYPE_CANNOT_DEDUCE_AUTO_TYPE = 10003;
|
||||
int TYPE_UNKNOWN_FOR_EXPRESSION = 10004;
|
||||
int TYPE_UNKNOWN_FOR_EXPRESSION = 10004;
|
||||
int TYPE_NOT_PERSISTED = 10005;
|
||||
|
||||
/**
|
||||
* Returns the ID of the problem.
|
||||
|
|
|
@ -13,6 +13,9 @@ package org.eclipse.cdt.internal.core.dom.parser.c;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
|
||||
|
@ -22,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class CQualifierType implements ICQualifierType, ITypeContainer, ISerializableType {
|
||||
|
@ -91,23 +95,26 @@ public class CQualifierType implements ICQualifierType, ITypeContainer, ISeriali
|
|||
* @see org.eclipse.cdt.core.dom.ast.IQualifierType#getType()
|
||||
*/
|
||||
private IType resolveType(ICASTDeclSpecifier declSpec) {
|
||||
IType t = null;
|
||||
IBinding b = null;
|
||||
if (declSpec instanceof ICASTTypedefNameSpecifier) {
|
||||
ICASTTypedefNameSpecifier nameSpec = (ICASTTypedefNameSpecifier) declSpec;
|
||||
t = (IType) nameSpec.getName().resolveBinding();
|
||||
b = nameSpec.getName().resolveBinding();
|
||||
} else if (declSpec instanceof IASTElaboratedTypeSpecifier) {
|
||||
IASTElaboratedTypeSpecifier elabTypeSpec = (IASTElaboratedTypeSpecifier) declSpec;
|
||||
t = (IType) elabTypeSpec.getName().resolveBinding();
|
||||
b = elabTypeSpec.getName().resolveBinding();
|
||||
} else if (declSpec instanceof IASTCompositeTypeSpecifier) {
|
||||
IASTCompositeTypeSpecifier compTypeSpec = (IASTCompositeTypeSpecifier) declSpec;
|
||||
t = (IType) compTypeSpec.getName().resolveBinding();
|
||||
b = compTypeSpec.getName().resolveBinding();
|
||||
} else if (declSpec instanceof IASTEnumerationSpecifier) {
|
||||
t = new CEnumeration(((IASTEnumerationSpecifier) declSpec).getName());
|
||||
return new CEnumeration(((IASTEnumerationSpecifier) declSpec).getName());
|
||||
} else {
|
||||
t = new CBasicType((ICASTSimpleDeclSpecifier) declSpec);
|
||||
return new CBasicType((ICASTSimpleDeclSpecifier) declSpec);
|
||||
}
|
||||
|
||||
return t;
|
||||
if (b instanceof IType && !(b instanceof IProblemBinding))
|
||||
return (IType) b;
|
||||
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME);
|
||||
}
|
||||
|
||||
public IType getType() {
|
||||
|
|
|
@ -27,14 +27,12 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* Integral c++ type.
|
||||
*/
|
||||
public class CPPBasicType implements ICPPBasicType, ISerializableType {
|
||||
// mstodo replace with problem type
|
||||
public static int UNIQUE_TYPE_QUALIFIER= -1;
|
||||
private final Kind fKind;
|
||||
private final int fModifiers;
|
||||
private IASTExpression fExpression;
|
||||
|
||||
public CPPBasicType(Kind kind, int qualifiers, IASTExpression expression) {
|
||||
if (kind == Kind.eUnspecified && qualifiers != UNIQUE_TYPE_QUALIFIER) {
|
||||
if (kind == Kind.eUnspecified) {
|
||||
if ( (qualifiers & (IS_COMPLEX | IS_IMAGINARY)) != 0) {
|
||||
fKind= Kind.eFloat;
|
||||
} else if ( (qualifiers & (IS_LONG | IS_SHORT | IS_SIGNED | IS_UNSIGNED | IS_LONG_LONG)) != 0 ) {
|
||||
|
@ -102,9 +100,6 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
|
|||
if (object == this)
|
||||
return true;
|
||||
|
||||
if (fModifiers == UNIQUE_TYPE_QUALIFIER)
|
||||
return false;
|
||||
|
||||
if (object instanceof ITypedef)
|
||||
return object.isSameType(this);
|
||||
|
||||
|
|
|
@ -1974,7 +1974,7 @@ public class CPPTemplates {
|
|||
if (map != null && pType != null) {
|
||||
pType= instantiateType(pType, map, -1, null);
|
||||
}
|
||||
if (argType instanceof ICPPUnknownType || isNonTypeArgumentConvertible(pType, argType)) {
|
||||
if (argType instanceof ICPPUnknownType || argType instanceof ISemanticProblem || isNonTypeArgumentConvertible(pType, argType)) {
|
||||
return new CPPTemplateArgument(arg.getNonTypeValue(), pType);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -81,6 +81,7 @@ public class ParserMessages {
|
|||
case ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD: return "ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD";
|
||||
case ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE: return "ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE";
|
||||
case ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION: return "ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION";
|
||||
case ISemanticProblem.TYPE_NOT_PERSISTED: return "ISemanticProblem.TYPE_NOT_PERSISTED";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -71,4 +71,7 @@ ISemanticProblem.TYPE_UNRESOLVED_NAME=Type depends on an unresolved name
|
|||
ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD=Illegally auto-typed static field
|
||||
ISemanticProblem.TYPE_CANNOT_DEDUCE_AUTO_TYPE=Failure to determine auto-type
|
||||
ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION=Failure to determine type of expression
|
||||
ISemanticProblem.TYPE_NOT_PERSISTED=Failure to store type in the index
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
|
@ -94,7 +94,7 @@ public class PDOMCPPArgumentList {
|
|||
for (int i=0; i<len; i++) {
|
||||
IType type= linkage.loadType(rec);
|
||||
if (type == null) {
|
||||
type= new CPPBasicType(Kind.eUnspecified,CPPBasicType.UNIQUE_TYPE_QUALIFIER);
|
||||
type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
}
|
||||
final long nonTypeValRec= db.getRecPtr(rec+VALUE_OFFSET);
|
||||
if (nonTypeValRec != 0) {
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
|
@ -146,7 +146,7 @@ public class PDOMCPPTemplateParameterMap {
|
|||
throws CoreException {
|
||||
IType type= linkage.loadType(rec + TYPE_OFFSET);
|
||||
if (type == null) {
|
||||
type= new CPPBasicType(Kind.eUnspecified, CPPBasicType.UNIQUE_TYPE_QUALIFIER);
|
||||
type= new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
|
||||
}
|
||||
final long nonTypeValRec= db.getRecPtr(rec+VALUE_OFFSET);
|
||||
ICPPTemplateArgument arg;
|
||||
|
|
Loading…
Add table
Reference in a new issue