mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 00:36:16 +02:00
Bug 472818 - HeuristicResolver: support for EvalFunctionCall
Change-Id: Id0a76d748d5a03d70b8f75ca0e8d776d824b88e5
This commit is contained in:
parent
01a74ee5f7
commit
6df72650e4
3 changed files with 27 additions and 19 deletions
|
@ -12,7 +12,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType;
|
|
||||||
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.valueCategoryFromFunctionCall;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType;
|
||||||
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.CVTYPE;
|
||||||
|
@ -34,7 +33,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
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.dom.parser.cpp.CPPFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
@ -124,24 +122,13 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
|
||||||
ICPPFunction overload = getOverload(point);
|
ICPPFunction overload = getOverload(point);
|
||||||
if (overload != null)
|
if (overload != null)
|
||||||
return ExpressionTypes.typeFromFunctionCall(overload);
|
return ExpressionTypes.typeFromFunctionCall(overload);
|
||||||
|
|
||||||
final ICPPEvaluation arg0 = fArguments[0];
|
ICPPEvaluation function = fArguments[0];
|
||||||
IType t= SemanticUtil.getNestedType(arg0.getType(point), TDEF | REF | CVTYPE);
|
IType result = ExpressionTypes.typeFromFunctionCall(function.getType(point));
|
||||||
if (t instanceof ICPPClassType) {
|
if (function instanceof EvalMemberAccess) {
|
||||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
result = ExpressionTypes.restoreTypedefs(result, ((EvalMemberAccess) function).getOwnerType());
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
if (t instanceof IPointerType) {
|
|
||||||
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE);
|
|
||||||
}
|
|
||||||
if (t instanceof IFunctionType) {
|
|
||||||
t = typeFromReturnType(((IFunctionType) t).getReturnType());
|
|
||||||
if (arg0 instanceof EvalMemberAccess) {
|
|
||||||
t= ExpressionTypes.restoreTypedefs(t, ((EvalMemberAccess) arg0).getOwnerType());
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CQualifierType;
|
import org.eclipse.cdt.internal.core.dom.parser.c.CQualifierType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +62,18 @@ public class ExpressionTypes {
|
||||||
}
|
}
|
||||||
return ValueCategory.PRVALUE;
|
return ValueCategory.PRVALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IType typeFromFunctionCall(IType functionType) {
|
||||||
|
IType t= SemanticUtil.getNestedType(functionType, TDEF | REF | CVTYPE);
|
||||||
|
if (t instanceof IPointerType) {
|
||||||
|
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE);
|
||||||
|
}
|
||||||
|
if (t instanceof IFunctionType) {
|
||||||
|
t = typeFromReturnType(((IFunctionType) t).getReturnType());
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
return ProblemType.UNKNOWN_FOR_EXPRESSION;
|
||||||
|
}
|
||||||
|
|
||||||
public static IType typeFromFunctionCall(ICPPFunction function) {
|
public static IType typeFromFunctionCall(ICPPFunction function) {
|
||||||
final ICPPFunctionType ft = function.getType();
|
final ICPPFunctionType ft = function.getType();
|
||||||
|
|
|
@ -154,6 +154,14 @@ public class HeuristicResolver {
|
||||||
return typeForBinding(candidates[0]);
|
return typeForBinding(candidates[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (evaluation instanceof EvalFunctionCall) {
|
||||||
|
EvalFunctionCall evalFunctionCall = (EvalFunctionCall) evaluation;
|
||||||
|
ICPPEvaluation function = evalFunctionCall.getArguments()[0];
|
||||||
|
IType functionType = function.getType(point);
|
||||||
|
if (functionType instanceof ICPPUnknownType) {
|
||||||
|
functionType = resolveUnknownType((ICPPUnknownType) functionType, point);
|
||||||
|
}
|
||||||
|
return ExpressionTypes.typeFromFunctionCall(functionType);
|
||||||
}
|
}
|
||||||
// TODO(nathanridge): Handle more cases.
|
// TODO(nathanridge): Handle more cases.
|
||||||
} else if (type instanceof ICPPUnknownMemberClass) {
|
} else if (type instanceof ICPPUnknownMemberClass) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue