1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Added point parameter to the CompositeValue.create(ICPPClassType) method

Change-Id: Ia3bb0dc48c90496242a696ec7126be2fd71e47fd
This commit is contained in:
Sergey Prigogin 2017-02-27 15:11:52 -08:00 committed by Gerrit Code Review @ Eclipse.org
parent c7632069df
commit 3f8d51e65b
4 changed files with 11 additions and 11 deletions

View file

@ -186,23 +186,23 @@ public final class CompositeValue implements IValue {
* determined by the default member initializers only. Constructors are not considered
* when determining the values of the fields.
*/
public static CompositeValue create(ICPPClassType classType) {
public static CompositeValue create(ICPPClassType classType, IASTNode point) {
Set<ICPPClassType> recursionProtectionSet = fCreateInProgress.get();
if (!recursionProtectionSet.add(classType)) {
return new CompositeValue(null, ICPPEvaluation.EMPTY_ARRAY);
}
try {
ActivationRecord record = new ActivationRecord();
ICPPEvaluation[] values = new ICPPEvaluation[ClassTypeHelper.getFields(classType, null).length];
ICPPEvaluation[] values = new ICPPEvaluation[ClassTypeHelper.getFields(classType, point).length];
// Recursively create all the base class member variables.
ICPPBase[] bases = ClassTypeHelper.getBases(classType, null);
ICPPBase[] bases = ClassTypeHelper.getBases(classType, point);
for (ICPPBase base : bases) {
IBinding baseClass = base.getBaseClass();
if (baseClass instanceof ICPPClassType) {
ICPPClassType baseClassType = (ICPPClassType) baseClass;
ICPPField[] baseFields = ClassTypeHelper.getDeclaredFields(baseClassType, null);
IValue compValue = CompositeValue.create(baseClassType);
ICPPField[] baseFields = ClassTypeHelper.getDeclaredFields(baseClassType, point);
IValue compValue = CompositeValue.create(baseClassType, point);
for (ICPPField baseField : baseFields) {
int fieldPos = CPPASTFieldReference.getFieldPosition(baseField);
if (fieldPos == -1) {
@ -217,7 +217,7 @@ public final class CompositeValue implements IValue {
}
}
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, null);
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, point);
for (ICPPField field : fields) {
if (field.isStatic())
continue;

View file

@ -141,7 +141,7 @@ public final class EvalConstructor extends CPPDependentEvaluation {
return this;
}
final ICPPClassType classType = (ICPPClassType) unwrappedType;
final CompositeValue compositeValue = CompositeValue.create(classType);
final CompositeValue compositeValue = CompositeValue.create(classType, context.getPoint());
ICPPEvaluation[] argList = evaluateArguments(fArguments, callSiteRecord, context);
EvalFixed constructedObject = new EvalFixed(fType, ValueCategory.PRVALUE, compositeValue);
CPPVariable binding = new CPPVariable(TEMP_NAME);

View file

@ -150,7 +150,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
ICPPClassType classType = (ICPPClassType) fInputType;
IBinding ctor = getConstructor(point);
if (EvalUtil.isCompilerGeneratedCtor(ctor)) {
return CompositeValue.create(classType);
return CompositeValue.create(classType, point);
} else if (ctor == AGGREGATE_INITIALIZATION) {
return CompositeValue.create(new EvalInitList(fArguments, getTemplateDefinition()),
classType, point);

View file

@ -88,7 +88,7 @@ public final class ExecDeclarator implements ICPPExecution {
private ICPPEvaluation createInitialValue(IType type, ActivationRecord record,
ConstexprEvaluationContext context) {
if (initializerEval == null)
return createDefaultInitializedCompositeValue(type);
return createDefaultInitializedCompositeValue(type, context.getPoint());
IType nestedType = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
@ -125,14 +125,14 @@ public final class ExecDeclarator implements ICPPExecution {
computedInitializerEval.getValue(context.getPoint()));
}
private static ICPPEvaluation createDefaultInitializedCompositeValue(IType type) {
private static ICPPEvaluation createDefaultInitializedCompositeValue(IType type, IASTNode point) {
if (!(type instanceof ICPPClassType)) {
return EvalFixed.INCOMPLETE;
}
ICPPClassType classType = (ICPPClassType) type;
// TODO(nathanridge): CompositeValue.create() only consider default member initializers, not
// constructors. Should we be considering constructors here as well?
IValue compositeValue = CompositeValue.create(classType);
IValue compositeValue = CompositeValue.create(classType, point);
EvalFixed initialValue = new EvalFixed(type, ValueCategory.PRVALUE, compositeValue);
return initialValue;
}