Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-01-31 20:50:29 -0500
committerNathan Ridge2017-01-31 20:51:30 -0500
commit759a5d9a8e7123a0469ba912a0dc5adb8f185612 (patch)
treee129881e9b06e99f70bef68da0140590d8756443
parentdb59f8081204b3fc45d17b4c9bc80c0520d4aa79 (diff)
downloadorg.eclipse.cdt-759a5d9a8e7123a0469ba912a0dc5adb8f185612.tar.gz
org.eclipse.cdt-759a5d9a8e7123a0469ba912a0dc5adb8f185612.tar.xz
org.eclipse.cdt-759a5d9a8e7123a0469ba912a0dc5adb8f185612.zip
Improve the propagation of the point of instantiation in CompositeValue
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java23
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java3
2 files changed, 16 insertions, 10 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java
index 3ea358fbfd..3bb2101f05 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java
@@ -109,7 +109,7 @@ public final class CompositeValue implements IValue {
* Creates a value representing an instance of the given array type initialized with
* the elements of the given initializer list.
*/
- public static IValue create(EvalInitList initList, IArrayType type) {
+ public static IValue create(EvalInitList initList, IArrayType type, IASTNode point) {
Number arraySize = type.getSize().numberValue();
if (arraySize == null) {
// Array size is dependent. TODO: Handle this?
@@ -123,8 +123,8 @@ public final class CompositeValue implements IValue {
ICPPEvaluation[] values = new ICPPEvaluation[arraySize.intValue()];
for (int i = 0; i < initList.getClauses().length; i++) {
ICPPEvaluation eval = initList.getClauses()[i];
- IValue value = getValue(elementType, eval);
- values[i] = new EvalFixed(elementType, eval.getValueCategory(null), value);
+ IValue value = getValue(elementType, eval, point);
+ values[i] = new EvalFixed(elementType, eval.getValueCategory(point), value);
}
return new CompositeValue(initList, values);
}
@@ -132,12 +132,12 @@ public final class CompositeValue implements IValue {
/**
* Gets the value of an evaluation, interpreted as a value of the given type.
*/
- private static IValue getValue(IType type, ICPPEvaluation eval) {
+ private static IValue getValue(IType type, ICPPEvaluation eval, IASTNode point) {
IValue value;
if (type instanceof IArrayType && eval instanceof EvalInitList) {
- value = CompositeValue.create((EvalInitList) eval, (IArrayType) type);
+ value = CompositeValue.create((EvalInitList) eval, (IArrayType) type, point);
} else if (type instanceof ICompositeType && eval instanceof EvalInitList) {
- value = CompositeValue.create((EvalInitList) eval, (ICompositeType) type);
+ value = CompositeValue.create((EvalInitList) eval, (ICompositeType) type, point);
} else if (eval instanceof EvalInitList) {
value = IntegralValue.UNKNOWN;
} else {
@@ -150,8 +150,13 @@ public final class CompositeValue implements IValue {
* Creates a value representing an instance of the given composite type initialized with
* the elements of the given initializer list.
*/
- public static IValue create(EvalInitList initList, ICompositeType type) {
- IField[] fields = type.getFields();
+ public static IValue create(EvalInitList initList, ICompositeType type, IASTNode point) {
+ IField[] fields;
+ if (type instanceof ICPPClassType) {
+ fields = ClassTypeHelper.getFields((ICPPClassType) type, point);
+ } else {
+ fields = type.getFields();
+ }
ICPPEvaluation[] values = new ICPPEvaluation[fields.length];
ICPPEvaluation[] clauses = initList.getClauses();
for (int i = 0; i < fields.length; i++) {
@@ -160,7 +165,7 @@ public final class CompositeValue implements IValue {
IField field = fields[i];
ICPPEvaluation eval = clauses[i];
IType fieldType = field.getType();
- IValue value = getValue(fieldType, eval);
+ IValue value = getValue(fieldType, eval, point);
values[i] = new EvalFixed(fieldType, eval.getValueCategory(null), value);
}
return new CompositeValue(initList, values);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java
index 963f0ac082..facf03fa36 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java
@@ -109,7 +109,8 @@ public final class ExecDeclarator implements ICPPExecution {
return createPointerValue(record, context, computedInitializerEval);
} else if (isArrayType(nestedType) && !isCStringType(nestedType)) {
if (computedInitializerEval instanceof EvalInitList) {
- IValue value = CompositeValue.create((EvalInitList) computedInitializerEval, (IArrayType) (type));
+ IValue value = CompositeValue.create((EvalInitList) computedInitializerEval,
+ (IArrayType) (type), context.getPoint());
return new EvalFixed(type, computedInitializerEval.getValueCategory(context.getPoint()), value);
} else {
// TODO(sprigogin): Should something else be done here?

Back to the top