Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2018-02-06 07:05:13 +0000
committerNathan Ridge2018-02-20 07:11:18 +0000
commitafb3ad751165f47c157f2e979fa3ce506458db1b (patch)
treebfedd3b590b83e0b850ce5e4c675dc9b8b6a3310
parentd8a9bdddb551fceaf0819b9655edc187aeba5fc9 (diff)
downloadorg.eclipse.cdt-afb3ad751165f47c157f2e979fa3ce506458db1b.tar.gz
org.eclipse.cdt-afb3ad751165f47c157f2e979fa3ce506458db1b.tar.xz
org.eclipse.cdt-afb3ad751165f47c157f2e979fa3ce506458db1b.zip
Bug 530762 - Add missing evaluation types to CPPCompositesFactory.getCompositeEvaluation()
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalReference.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java62
3 files changed, 80 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java
index 5dbf28390f..719f4adf21 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java
@@ -117,6 +117,14 @@ public final class EvalConstructor extends CPPDependentEvaluation {
public IType getType() {
return fType;
}
+
+ public ICPPConstructor getConstructor() {
+ return fConstructor;
+ }
+
+ public ICPPEvaluation[] getArguments() {
+ return fArguments;
+ }
@Override
public IValue getValue() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalReference.java
index 56a01b8038..66eef8c9c2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalReference.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalReference.java
@@ -27,7 +27,7 @@ public class EvalReference extends CPPDependentEvaluation {
protected IBinding referredBinding;
protected EvalCompositeAccess referredSubValue;
- EvalReference(ActivationRecord owningRecord, IBinding referredBinding, IBinding templateDefinition) {
+ public EvalReference(ActivationRecord owningRecord, IBinding referredBinding, IBinding templateDefinition) {
super(templateDefinition);
this.owningRecord = owningRecord;
this.referredBinding = referredBinding;
@@ -37,7 +37,7 @@ public class EvalReference extends CPPDependentEvaluation {
this(owningRecord, referredBinding, findEnclosingTemplate(point));
}
- EvalReference(ActivationRecord owningRecord, EvalCompositeAccess referredSubValue, IBinding templateDefinition) {
+ public EvalReference(ActivationRecord owningRecord, EvalCompositeAccess referredSubValue, IBinding templateDefinition) {
super(templateDefinition);
this.owningRecord = owningRecord;
this.referredSubValue = referredSubValue;
@@ -47,6 +47,14 @@ public class EvalReference extends CPPDependentEvaluation {
EvalReference(ActivationRecord owningRecord, EvalCompositeAccess referredSubValue, IASTNode point) {
this(owningRecord, referredSubValue, findEnclosingTemplate(point));
}
+
+ public ActivationRecord getOwningRecord() {
+ return owningRecord;
+ }
+
+ public EvalCompositeAccess getReferredSubValue() {
+ return referredSubValue;
+ }
@Override
public final boolean isInitializerList() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
index 21f9e0e283..5e5f16ea90 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
@@ -91,8 +91,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinaryTypeId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalComma;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalCompositeAccess;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalCompoundStatementExpression;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalConditional;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalConstructor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionCall;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionSet;
@@ -101,6 +103,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalInitList;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalMemberAccess;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalNaryTypeId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalPackExpansion;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalPointer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalReference;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID;
@@ -340,6 +344,14 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
e= new EvalComma(a2, compositeTemplateDefinition);
return e;
}
+ if (eval instanceof EvalCompositeAccess) {
+ EvalCompositeAccess e = (EvalCompositeAccess) eval;
+ ICPPEvaluation a = e.getParent();
+ ICPPEvaluation a2 = getCompositeEvaluation(a);
+ if (a != a2)
+ e = new EvalCompositeAccess(a2, e.getElementId());
+ return e;
+ }
if (eval instanceof EvalCompoundStatementExpression) {
EvalCompoundStatementExpression e= (EvalCompoundStatementExpression) eval;
ICPPEvaluation a = e.getLastEvaluation();
@@ -360,6 +372,25 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
e= new EvalConditional(a2, b2, c2, e.isPositiveThrows(), e.isNegativeThrows(), compositeTemplateDefinition);
return e;
}
+ if (eval instanceof EvalConstructor) {
+ EvalConstructor e = (EvalConstructor) eval;
+ IType a = e.getType();
+ ICPPConstructor b = e.getConstructor();
+ ICPPEvaluation[] c = e.getArguments();
+ IType a2 = getCompositeType(a);
+ ICPPConstructor b2 = b;
+ if (b instanceof IIndexFragmentBinding) {
+ IBinding binding = getCompositeBinding((IIndexFragmentBinding) b);
+ if (binding instanceof ICPPConstructor) {
+ b2 = (ICPPConstructor) binding;
+ }
+ }
+ ICPPEvaluation[] c2 = getCompositeEvaluationArray(c);
+ if (a != a2 || b != b2 || c != c2 || templateDefinition != compositeTemplateDefinition) {
+ e = new EvalConstructor(a2, b2, c2, compositeTemplateDefinition);
+ }
+ return e;
+ }
if (eval instanceof EvalFixed) {
EvalFixed e= (EvalFixed) eval;
IType a = e.getType();
@@ -458,6 +489,37 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
e = new EvalPackExpansion(a2, compositeTemplateDefinition);
return e;
}
+ // EvalPointer is handled as a sub-case of EvalReference.
+ if (eval instanceof EvalReference) {
+ EvalReference e = (EvalReference) eval;
+ IBinding a = e.getReferredBinding();
+ // TODO: Does the ActivationRecord need conversion to composite bindings?
+ if (a != null) {
+ IBinding a2 = a;
+ if (a instanceof IIndexFragmentBinding) {
+ a2 = getCompositeBinding((IIndexFragmentBinding) a);
+ }
+ if (a != a2 || templateDefinition != compositeTemplateDefinition) {
+ e = new EvalReference(e.getOwningRecord(), a2, compositeTemplateDefinition);
+ }
+ } else {
+ EvalCompositeAccess b = e.getReferredSubValue();
+ EvalCompositeAccess b2 = b;
+ ICPPEvaluation composite = getCompositeEvaluation(b2);
+ if (eval instanceof EvalCompositeAccess) {
+ b2 = (EvalCompositeAccess) composite;
+ }
+ if (b != b2 || templateDefinition != compositeTemplateDefinition) {
+ if (e instanceof EvalPointer) {
+ e = new EvalPointer(e.getOwningRecord(), b2, compositeTemplateDefinition,
+ ((EvalPointer) e).getPosition());
+ } else {
+ e = new EvalReference(e.getOwningRecord(), b2, compositeTemplateDefinition);
+ }
+ }
+ }
+ return e;
+ }
if (eval instanceof EvalTypeId) {
EvalTypeId e= (EvalTypeId) eval;
IType a = e.getInputType();

Back to the top