mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 299911: Preserving typedefs in the evaluation.
This commit is contained in:
parent
cf08c60eda
commit
7ec08c36da
4 changed files with 26 additions and 22 deletions
|
@ -13,9 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
|||
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
|
@ -92,7 +90,9 @@ public class EvalBinary implements ICPPEvaluation {
|
|||
} else {
|
||||
ICPPFunction overload = getOverload(point);
|
||||
if (overload != null) {
|
||||
fType= ExpressionTypes.typeFromFunctionCall(overload);
|
||||
fType= ExpressionTypes.restoreTypedefs(
|
||||
ExpressionTypes.typeFromFunctionCall(overload),
|
||||
fArg1.getTypeOrFunctionSet(point), fArg2.getTypeOrFunctionSet(point));
|
||||
} else {
|
||||
fType= computeType(point);
|
||||
}
|
||||
|
@ -189,19 +189,21 @@ public class EvalBinary implements ICPPEvaluation {
|
|||
if (o != null)
|
||||
return typeFromFunctionCall(o);
|
||||
|
||||
IType type1 = prvalueType(fArg1.getTypeOrFunctionSet(point));
|
||||
final IType originalType1 = fArg1.getTypeOrFunctionSet(point);
|
||||
final IType type1 = prvalueTypeWithResolvedTypedefs(originalType1);
|
||||
if (type1 instanceof ISemanticProblem) {
|
||||
return type1;
|
||||
}
|
||||
|
||||
IType type2 = prvalueType(fArg2.getTypeOrFunctionSet(point));
|
||||
final IType originalType2 = fArg2.getTypeOrFunctionSet(point);
|
||||
final IType type2 = prvalueTypeWithResolvedTypedefs(originalType2);
|
||||
if (type2 instanceof ISemanticProblem) {
|
||||
return type2;
|
||||
}
|
||||
|
||||
IType type= CPPArithmeticConversion.convertCppOperandTypes(fOperator, type1, type2);
|
||||
if (type != null) {
|
||||
return type;
|
||||
return ExpressionTypes.restoreTypedefs(type, originalType1, originalType2);
|
||||
}
|
||||
|
||||
|
||||
|
@ -227,10 +229,10 @@ public class EvalBinary implements ICPPEvaluation {
|
|||
|
||||
case IASTBinaryExpression.op_plus:
|
||||
if (type1 instanceof IPointerType) {
|
||||
return type1;
|
||||
return ExpressionTypes.restoreTypedefs(type1, originalType1);
|
||||
}
|
||||
if (type2 instanceof IPointerType) {
|
||||
return type2;
|
||||
return ExpressionTypes.restoreTypedefs(type2, originalType2);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -239,7 +241,7 @@ public class EvalBinary implements ICPPEvaluation {
|
|||
if (type2 instanceof IPointerType) {
|
||||
return CPPVisitor.getPointerDiffType(point);
|
||||
}
|
||||
return type1;
|
||||
return originalType1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -112,7 +112,8 @@ public class EvalFunctionCall implements ICPPEvaluation {
|
|||
return ExpressionTypes.typeFromFunctionCall(overload);
|
||||
|
||||
|
||||
IType t= SemanticUtil.getNestedType(fArguments[0].getTypeOrFunctionSet(point), TDEF|REF|CVTYPE);
|
||||
final ICPPEvaluation arg0 = fArguments[0];
|
||||
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF|REF|CVTYPE);
|
||||
if (t instanceof ICPPClassType) {
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
@ -121,7 +122,11 @@ public class EvalFunctionCall implements ICPPEvaluation {
|
|||
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE);
|
||||
}
|
||||
if (t instanceof IFunctionType) {
|
||||
return typeFromReturnType(((IFunctionType) t).getReturnType());
|
||||
t = typeFromReturnType(((IFunctionType) t).getReturnType());
|
||||
if (arg0 instanceof EvalMemberAccess) {
|
||||
t= ExpressionTypes.restoreTypedefs(t, ((EvalMemberAccess) arg0).getOwnerType());
|
||||
}
|
||||
return t;
|
||||
}
|
||||
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
|||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromFunctionCall;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -182,7 +180,7 @@ public class EvalMemberAccess implements ICPPEvaluation {
|
|||
type= SemanticUtil.mapToAST(type, point);
|
||||
}
|
||||
|
||||
IType prValue= prvalueType(type);
|
||||
IType prValue= prvalueTypeWithResolvedTypedefs(type);
|
||||
if (prValue instanceof IPointerType) {
|
||||
return glvalueType(((IPointerType) prValue).getType());
|
||||
}
|
||||
|
|
|
@ -14,9 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
|||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||
import static org.eclipse.cdt.core.dom.ast.IASTUnaryExpression.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.glvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.*;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
|
@ -162,7 +160,7 @@ public class EvalUnary implements ICPPEvaluation {
|
|||
return new CPPPointerType(fArgument.getTypeOrFunctionSet(point));
|
||||
case op_star:
|
||||
IType type= fArgument.getTypeOrFunctionSet(point);
|
||||
type = prvalueType(type);
|
||||
type = prvalueTypeWithResolvedTypedefs(type);
|
||||
if (type instanceof IPointerType) {
|
||||
return glvalueType(((IPointerType) type).getType());
|
||||
}
|
||||
|
@ -179,8 +177,9 @@ public class EvalUnary implements ICPPEvaluation {
|
|||
case op_plus:
|
||||
case op_tilde:
|
||||
final IType t1 = prvalueType(fArgument.getTypeOrFunctionSet(point));
|
||||
final IType t2= CPPArithmeticConversion.promoteCppType(t1);
|
||||
return t2 != null ? t2 : t1;
|
||||
final IType t2 = SemanticUtil.getNestedType(t1, TDEF);
|
||||
final IType t3= CPPArithmeticConversion.promoteCppType(t2);
|
||||
return (t3 == null || t3 == t2) ? t1 : t3;
|
||||
}
|
||||
return fArgument.getTypeOrFunctionSet(point);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue