Skip to content

Commit d08fdac

Browse files
committed
fixup! Update clang/lib/Analysis/FlowSensitive/Value.cpp
add tests
1 parent b2a6821 commit d08fdac

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

clang/unittests/Analysis/FlowSensitive/ValueTest.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,20 @@ TEST(ValueTest, TopsEquivalent) {
4545
EXPECT_TRUE(areEquivalentValues(V2, V1));
4646
}
4747

48-
TEST(ValueTest, EquivalentValuesWithDifferentPropsEquivalent) {
48+
// The framework does not (currently) consider equivalence for values with
49+
// properties, leaving such to individual analyses.
50+
TEST(ValueTest, ValuesWithSamePropsDifferent) {
51+
Arena A;
52+
TopBoolValue Prop(A.makeAtomRef(Atom(0)));
53+
TopBoolValue V1(A.makeAtomRef(Atom(2)));
54+
TopBoolValue V2(A.makeAtomRef(Atom(3)));
55+
V1.setProperty("foo", Prop);
56+
V2.setProperty("foo", Prop);
57+
EXPECT_FALSE(areEquivalentValues(V1, V2));
58+
EXPECT_FALSE(areEquivalentValues(V2, V1));
59+
}
60+
61+
TEST(ValueTest, ValuesWithDifferentPropsDifferent) {
4962
Arena A;
5063
TopBoolValue Prop1(A.makeAtomRef(Atom(0)));
5164
TopBoolValue Prop2(A.makeAtomRef(Atom(1)));
@@ -57,6 +70,17 @@ TEST(ValueTest, EquivalentValuesWithDifferentPropsEquivalent) {
5770
EXPECT_FALSE(areEquivalentValues(V2, V1));
5871
}
5972

73+
TEST(ValueTest, ValuesWithDifferentNumberPropsDifferent) {
74+
Arena A;
75+
TopBoolValue Prop(A.makeAtomRef(Atom(0)));
76+
TopBoolValue V1(A.makeAtomRef(Atom(2)));
77+
TopBoolValue V2(A.makeAtomRef(Atom(3)));
78+
// Only set a property on `V1`.
79+
V1.setProperty("foo", Prop);
80+
EXPECT_FALSE(areEquivalentValues(V1, V2));
81+
EXPECT_FALSE(areEquivalentValues(V2, V1));
82+
}
83+
6084
TEST(ValueTest, DifferentKindsNotEquivalent) {
6185
Arena A;
6286
auto L = ScalarStorageLocation(QualType());

0 commit comments

Comments
 (0)