Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2018-11-10 01:10:14 -0500
committerNathan Ridge2018-11-17 03:02:51 -0500
commite082f73b56d8ea0f588f5ee8338d44b3f06b5f88 (patch)
tree385c49a7b8b1a829eec5802f3849010b645ffb5d /core/org.eclipse.cdt.core/parser/org
parent54f6c19de27012a9e7662ed5cfcbcf1377583bd6 (diff)
downloadorg.eclipse.cdt-e082f73b56d8ea0f588f5ee8338d44b3f06b5f88.tar.gz
org.eclipse.cdt-e082f73b56d8ea0f588f5ee8338d44b3f06b5f88.tar.xz
org.eclipse.cdt-e082f73b56d8ea0f588f5ee8338d44b3f06b5f88.zip
Bug 540957 - Implement equivalence checking for expressions
This is used for declaration matching in function templates. Change-Id: I80044304b2d9dfda085a13f0cfc040f1200a2e1c
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IValue.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CStringValue.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CompositeValue.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DependentValue.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FloatingPointValue.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IntegralValue.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java68
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java13
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompositeAccess.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompoundStatementExpression.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConstructor.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalNaryTypeId.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalPackExpansion.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalReference.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java2
30 files changed, 358 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IValue.java
index 3deacd0535..1a2019ef8e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IValue.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IValue.java
@@ -114,4 +114,10 @@ public interface IValue {
* @noreference This method is not intended to be referenced by clients.
*/
void marshal(ITypeMarshalBuffer buffer) throws CoreException;
+
+ /**
+ * Returns true if this value is equivalent to 'other' for declaration matching purposes.
+ * @noreference This method is not intended to be referenced by clients.
+ */
+ boolean isEquivalentTo(IValue other);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CStringValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CStringValue.java
index 9235135672..e22b6bc323 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CStringValue.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/CStringValue.java
@@ -241,4 +241,13 @@ public final class CStringValue implements IValue {
public String toString() {
return new String(fFixedValue);
}
+
+ @Override
+ public boolean isEquivalentTo(IValue other) {
+ if (!(other instanceof CStringValue)) {
+ return false;
+ }
+ CStringValue o = (CStringValue) other;
+ return fFixedValue.equals(o.fFixedValue);
+ }
} \ No newline at end of file
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 8a282422d1..0bc1c14ca3 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
@@ -299,4 +299,25 @@ public final class CompositeValue implements IValue {
}
return new CompositeValue(evaluation, values);
}
+
+ @Override
+ public boolean isEquivalentTo(IValue other) {
+ if (!(other instanceof CompositeValue)) {
+ return false;
+ }
+ CompositeValue o = (CompositeValue) other;
+ if (!((evaluation == null && o.evaluation == null) ||
+ (evaluation.isEquivalentTo(o.evaluation)))) {
+ return false;
+ }
+ if (values.length != o.values.length) {
+ return false;
+ }
+ for (int i = 0; i < values.length; i++) {
+ if (!values[i].isEquivalentTo(o.values[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DependentValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DependentValue.java
index e080b6d695..48b7d525cd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DependentValue.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DependentValue.java
@@ -128,4 +128,12 @@ public class DependentValue implements IValue {
return new DependentValue(fEvaluation);
}
+ @Override
+ public boolean isEquivalentTo(IValue other) {
+ if (!(other instanceof DependentValue)) {
+ return false;
+ }
+ DependentValue o = (DependentValue) other;
+ return fEvaluation.isEquivalentTo(o.fEvaluation);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FloatingPointValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FloatingPointValue.java
index 8b5fc13e50..56e4ff14a8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FloatingPointValue.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FloatingPointValue.java
@@ -163,4 +163,13 @@ public final class FloatingPointValue implements IValue {
public static IValue unmarshal(short firstBytes, ITypeMarshalBuffer buf) throws CoreException {
return new FloatingPointValue(buf.getCharArray());
}
+
+ @Override
+ public boolean isEquivalentTo(IValue other) {
+ if (!(other instanceof FloatingPointValue)) {
+ return false;
+ }
+ FloatingPointValue o = (FloatingPointValue) other;
+ return fFixedValue.equals(o.fFixedValue);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IntegralValue.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IntegralValue.java
index 8dd0a65d05..ccb02dfdaf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IntegralValue.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IntegralValue.java
@@ -65,7 +65,6 @@ public class IntegralValue implements IValue {
private static int sUnique= 0;
- // The following invariant always holds: (fFixedValue == null) != (fEvaluation == null)
private final char[] fFixedValue;
private IntegralValue(char[] fixedValue) {
@@ -292,4 +291,13 @@ public class IntegralValue implements IValue {
public IValue clone() {
return new IntegralValue(Arrays.copyOf(fFixedValue, fFixedValue.length));
}
+
+ @Override
+ public boolean isEquivalentTo(IValue other) {
+ if (!(other instanceof IntegralValue)) {
+ return false;
+ }
+ IntegralValue o = (IntegralValue) other;
+ return fFixedValue.equals(o.fFixedValue);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java
index df14da0224..aa854a935a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java
@@ -46,6 +46,13 @@ public interface ICPPEvaluation {
* @param point the point of instantiation, determines the scope for name lookups
*/
boolean isConstantExpression();
+
+
+ /**
+ * Returns {@code true} if this expression is equivalent to 'other' for
+ * declaration matching purposes.
+ */
+ boolean isEquivalentTo(ICPPEvaluation other);
/**
* Returns the type of the expression.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java
index be9b4d90b2..d657c3bb2f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPEvaluation.java
@@ -212,4 +212,72 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
}
return argument;
}
+
+ protected static boolean areEquivalentOrNull(ICPPEvaluation a, ICPPEvaluation b) {
+ if (a == null) {
+ return (b == null);
+ }
+ return a.isEquivalentTo(b);
+ }
+
+ protected static boolean areEquivalentEvaluations(ICPPEvaluation[] a, ICPPEvaluation[] b) {
+ if (a == null) {
+ return (b == null);
+ }
+ if (a.length != b.length) {
+ return false;
+ }
+ for (int i = 0; i < a.length; i++) {
+ if (!a[i].isEquivalentTo(b[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ protected static boolean areEquivalentArguments(ICPPTemplateArgument[] a, ICPPTemplateArgument[] b) {
+ if (a == null) {
+ return (b == null);
+ }
+ if (a.length != b.length) {
+ return false;
+ }
+ for (int i = 0; i < a.length; i++) {
+ if (!a[i].isSameValue(b[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ protected static boolean areEquivalentTypes(IType[] a, IType[] b) {
+ if (a == null) {
+ return (b == null);
+ }
+ if (a.length != b.length) {
+ return false;
+ }
+ for (int i = 0; i < a.length; i++) {
+ if (!a[i].isSameType(b[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ protected static <T extends IBinding> boolean areEquivalentBindings(T[] a, T[] b) {
+ if (a == null) {
+ return (b == null);
+ }
+ if (a.length != b.length) {
+ return false;
+ }
+ for (int i = 0; i < a.length; i++) {
+ if (!a[i].equals(b[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java
index 3bfb20dc58..878c59f13f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionSet.java
@@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
@@ -111,4 +112,15 @@ public class CPPFunctionSet implements ICPPTwoPhaseBinding {
return super.toString();
}
}
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof CPPFunctionSet)) {
+ return false;
+ }
+ CPPFunctionSet o = (CPPFunctionSet) other;
+ return CPPEvaluation.areEquivalentBindings(fBindings, o.fBindings)
+ && fName == o.fName
+ && CPPEvaluation.areEquivalentArguments(fTemplateArguments, o.fTemplateArguments);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java
index 4169813f58..b7a71b1c1e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java
@@ -256,6 +256,17 @@ public class EvalBinary extends CPPDependentEvaluation {
}
return fIsConstantExpression;
}
+
+ @Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalBinary)) {
+ return false;
+ }
+ EvalBinary o = (EvalBinary) other;
+ return fOperator == o.fOperator
+ && fArg1.isEquivalentTo(o.fArg1)
+ && fArg2.isEquivalentTo(o.fArg2);
+ }
private boolean computeIsConstantExpression() {
return fArg1.isConstantExpression()
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java
index 50e885ea2f..ea85be12f2 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java
@@ -108,6 +108,17 @@ public class EvalBinaryTypeId extends CPPDependentEvaluation {
public boolean isConstantExpression() {
return true;
}
+
+ @Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalBinaryTypeId)) {
+ return false;
+ }
+ EvalBinaryTypeId o = (EvalBinaryTypeId) other;
+ return fOperator == o.fOperator
+ && fType1.isSameType(o.fType1)
+ && fType2.isSameType(o.fType2);
+ }
@Override
public ValueCategory getValueCategory() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
index 078ed7d60a..68dec3e00c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
@@ -261,6 +261,19 @@ public class EvalBinding extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalBinding)) {
+ return false;
+ }
+ EvalBinding o = (EvalBinding) other;
+ if (fBinding != null) {
+ return fBinding == o.fBinding;
+ }
+ return fParameterOwner == o.fParameterOwner
+ && fParameterPosition == o.fParameterPosition;
+ }
+
+ @Override
public IType getType() {
if (fType == null) {
fType= computeType();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java
index d0a775e3a3..61b7ad3624 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java
@@ -96,6 +96,15 @@ public class EvalComma extends CPPDependentEvaluation {
return true;
}
+ @Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalComma)) {
+ return false;
+ }
+ EvalComma o = (EvalComma) other;
+ return areEquivalentEvaluations(fArguments, o.fArguments);
+ }
+
public ICPPFunction[] getOverloads() {
if (fOverloads == null) {
fOverloads= computeOverloads();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompositeAccess.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompositeAccess.java
index 6058ff7247..51d4a1351a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompositeAccess.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompositeAccess.java
@@ -79,6 +79,16 @@ public final class EvalCompositeAccess implements ICPPEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalCompositeAccess)) {
+ return false;
+ }
+ EvalCompositeAccess o = (EvalCompositeAccess) other;
+ return parent.isEquivalentTo(o.parent)
+ && elementId == o.elementId;
+ }
+
+ @Override
public IType getType() {
IType type = getParent().getType();
type = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompoundStatementExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompoundStatementExpression.java
index 85e2eb1a4b..58ce0abb3f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompoundStatementExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompoundStatementExpression.java
@@ -74,6 +74,15 @@ public class EvalCompoundStatementExpression extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalCompoundStatementExpression)) {
+ return false;
+ }
+ EvalCompoundStatementExpression o = (EvalCompoundStatementExpression) other;
+ return fDelegate.isEquivalentTo(o.fDelegate);
+ }
+
+ @Override
public IType getType() {
return fDelegate.getType();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java
index 32c39bea94..14414e7c53 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java
@@ -164,6 +164,17 @@ public class EvalConditional extends CPPDependentEvaluation {
&& fNegative.isConstantExpression();
}
+ @Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalConditional)) {
+ return false;
+ }
+ EvalConditional o = (EvalConditional) other;
+ return fCondition.isEquivalentTo(o.fCondition)
+ && areEquivalentOrNull(fPositive, o.fPositive)
+ && fNegative.isEquivalentTo(o.fNegative);
+ }
+
private void evaluate() {
if (fValueCategory != null)
return;
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 719f4adf21..0353a1c097 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
@@ -114,6 +114,17 @@ public final class EvalConstructor extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalConstructor)) {
+ return false;
+ }
+ EvalConstructor o = (EvalConstructor) other;
+ return fType.isSameType(o.fType)
+ && fConstructor == o.fConstructor
+ && areEquivalentEvaluations(fArguments, o.fArguments);
+ }
+
+ @Override
public IType getType() {
return fType;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java
index 3a48ae0eac..d80ead28f5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java
@@ -112,6 +112,16 @@ public final class EvalFixed extends CPPEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalFixed)) {
+ return false;
+ }
+ EvalFixed o = (EvalFixed) other;
+ return fType.isSameType(o.fType)
+ && fValue.isEquivalentTo(o.fValue);
+ }
+
+ @Override
public IType getType() {
return fType;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java
index cc3970425b..93eb3a7e8c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java
@@ -126,6 +126,15 @@ public final class EvalFunctionCall extends CPPDependentEvaluation {
private boolean computeIsConstantExpression() {
return areAllConstantExpressions(fArguments) && isNullOrConstexprFunc(getOverload());
}
+
+ @Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalFunctionCall)) {
+ return false;
+ }
+ EvalFunctionCall o = (EvalFunctionCall) other;
+ return areEquivalentEvaluations(fArguments, o.fArguments);
+ }
public ICPPFunction getOverload() {
if (fOverload == CPPFunction.UNINITIALIZED_FUNCTION) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java
index 44c0bc953a..672446348e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java
@@ -159,6 +159,15 @@ public class EvalFunctionSet extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalFunctionSet)) {
+ return false;
+ }
+ EvalFunctionSet o = (EvalFunctionSet) other;
+ return fFunctionSet.equals(o.fFunctionSet);
+ }
+
+ @Override
public IType getType() {
return new FunctionSetType(fFunctionSet, fAddressOf);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
index 227118f5cf..5888ed1b2f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
@@ -52,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
@@ -156,6 +157,21 @@ public class EvalID extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalID)) {
+ return false;
+ }
+ EvalID o = (EvalID) other;
+ return areEquivalentOrNull(fFieldOwner, o.fFieldOwner)
+ && CharArrayUtils.equals(fName, o.fName)
+ && fNameOwner == o.fNameOwner
+ && fAddressOf == o.fAddressOf
+ && fQualified == o.fQualified
+ && fIsPointerDeref == o.fIsPointerDeref
+ && areEquivalentArguments(fTemplateArgs, o.fTemplateArgs);
+ }
+
+ @Override
public IType getType() {
return new TypeOfDependentExpression(this);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java
index be8279912f..ed0f65e21e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java
@@ -87,6 +87,15 @@ public class EvalInitList extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalInitList)) {
+ return false;
+ }
+ EvalInitList o = (EvalInitList) other;
+ return areEquivalentEvaluations(fClauses, o.fClauses);
+ }
+
+ @Override
public IType getType() {
return new InitializerListType(this);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java
index af5622c8d3..8ba9a042bf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java
@@ -188,6 +188,18 @@ public class EvalMemberAccess extends CPPDependentEvaluation {
return false;
}
+ @Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalMemberAccess)) {
+ return false;
+ }
+ EvalMemberAccess o = (EvalMemberAccess) other;
+ return fOwnerType.isSameType(o.fOwnerType)
+ && fMember == o.fMember
+ && fOwnerValueCategory == o.fOwnerValueCategory
+ && fIsPointerDeref == o.fIsPointerDeref;
+ }
+
public static IType getFieldOwnerType(IType fieldOwnerExpressionType, boolean isDeref,
Collection<ICPPFunction> functionBindings, boolean returnDependent) {
IType type= fieldOwnerExpressionType;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalNaryTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalNaryTypeId.java
index 1a9d27f51e..151f76f788 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalNaryTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalNaryTypeId.java
@@ -85,6 +85,16 @@ public class EvalNaryTypeId extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalNaryTypeId)) {
+ return false;
+ }
+ EvalNaryTypeId o = (EvalNaryTypeId) other;
+ return fOperator == o.fOperator
+ && areEquivalentTypes(fOperands, o.fOperands);
+ }
+
+ @Override
public IType getType() {
switch (fOperator) {
case __is_trivially_constructible:
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalPackExpansion.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalPackExpansion.java
index bea59df460..e032a52c21 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalPackExpansion.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalPackExpansion.java
@@ -70,6 +70,15 @@ public class EvalPackExpansion extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalPackExpansion)) {
+ return false;
+ }
+ EvalPackExpansion o = (EvalPackExpansion) other;
+ return fExpansionPattern.isEquivalentTo(o.fExpansionPattern);
+ }
+
+ @Override
public IType getType() {
if (fType == null) {
IType type = fExpansionPattern.getType();
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 66eef8c9c2..7cad7396e4 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
@@ -82,6 +82,13 @@ public class EvalReference extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ // This probably doesn't need to be implemented as this evaluation type
+ // only arises as an intermediate artifact during constexpr processing.
+ return false;
+ }
+
+ @Override
public IType getType() {
return getTargetEvaluation().getType();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
index 38e30b88ca..1b82b23890 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
@@ -232,6 +232,18 @@ public class EvalTypeId extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalTypeId)) {
+ return false;
+ }
+ EvalTypeId o = (EvalTypeId) other;
+ return fInputType.isSameType(o.fInputType)
+ && areEquivalentEvaluations(fArguments, o.fArguments)
+ && fRepresentsNewExpression == o.fRepresentsNewExpression
+ && fUsesBracedInitList == o.fUsesBracedInitList;
+ }
+
+ @Override
public ValueCategory getValueCategory() {
return valueCategoryFromReturnType(fInputType);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java
index 1f70e61deb..bd429fbfe1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java
@@ -171,6 +171,16 @@ public class EvalUnary extends CPPDependentEvaluation {
&& isNullOrConstexprFunc(getOverload());
}
+ @Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalUnary)) {
+ return false;
+ }
+ EvalUnary o = (EvalUnary) other;
+ return fOperator == o.fOperator
+ && fArgument.isEquivalentTo(o.fArgument);
+ }
+
public ICPPFunction getOverload() {
if (fOverload == CPPFunction.UNINITIALIZED_FUNCTION) {
fOverload= computeOverload();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
index 2e3beb5738..a13c16fad6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
@@ -137,6 +137,16 @@ public class EvalUnaryTypeID extends CPPDependentEvaluation {
}
@Override
+ public boolean isEquivalentTo(ICPPEvaluation other) {
+ if (!(other instanceof EvalUnaryTypeID)) {
+ return false;
+ }
+ EvalUnaryTypeID o = (EvalUnaryTypeID) other;
+ return fOperator == o.fOperator
+ && fOrigType.isSameType(o.fOrigType);
+ }
+
+ @Override
public IType getType() {
if (fType == null)
fType= computeType();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
index 1663cf1446..ab7d0f8594 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
@@ -65,7 +65,7 @@ public class TypeOfDependentExpression extends CPPUnknownBinding implements ICPP
@Override
public boolean isSameType(IType type) {
return type instanceof TypeOfDependentExpression
- && fEvaluation == ((TypeOfDependentExpression) type).fEvaluation;
+ && fEvaluation.isEquivalentTo(((TypeOfDependentExpression) type).fEvaluation);
}
@Override

Back to the top