1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[clang-tidy] remove duplicate fixes of alias checkers

when both a check and its alias are enabled, we should only take the fixes of one of them and not both.
This patch fixes bug 45577
https://bugs.llvm.org/show_bug.cgi?id=45577

Reviewed By: aaron.ballman, njames93

Differential Revision: https://reviews.llvm.org/D80753
This commit is contained in:
Daniel 2020-06-19 20:40:03 +01:00 committed by Nathan James
parent 46f661f4a4
commit ec554713c8
2 changed files with 84 additions and 0 deletions

View File

@ -248,6 +248,26 @@ public:
return count(MapEntry.getKey());
}
/// equal - check whether both of the containers are equal.
bool operator==(const StringMap &RHS) const {
if (size() != RHS.size())
return false;
for (const auto &KeyValue : *this) {
auto FindInRHS = RHS.find(KeyValue.getKey());
if (FindInRHS == RHS.end())
return false;
if (!(KeyValue.getValue() == FindInRHS->getValue()))
return false;
}
return true;
}
bool operator!=(const StringMap &RHS) const { return !(*this == RHS); }
/// insert - Insert the specified key/value pair into the map. If the key
/// already exists in the map, return false and ignore the request, otherwise
/// insert it and return true.

View File

@ -387,6 +387,70 @@ TEST_F(StringMapTest, MoveAssignment) {
ASSERT_EQ(B.count("x"), 0u);
}
TEST_F(StringMapTest, EqualEmpty) {
StringMap<int> A;
StringMap<int> B;
ASSERT_TRUE(A == B);
ASSERT_FALSE(A != B);
ASSERT_TRUE(A == A); // self check
}
TEST_F(StringMapTest, EqualWithValues) {
StringMap<int> A;
A["A"] = 1;
A["B"] = 2;
A["C"] = 3;
A["D"] = 3;
StringMap<int> B;
B["A"] = 1;
B["B"] = 2;
B["C"] = 3;
B["D"] = 3;
ASSERT_TRUE(A == B);
ASSERT_TRUE(B == A);
ASSERT_FALSE(A != B);
ASSERT_FALSE(B != A);
ASSERT_TRUE(A == A); // self check
}
TEST_F(StringMapTest, NotEqualMissingKeys) {
StringMap<int> A;
A["A"] = 1;
A["B"] = 2;
StringMap<int> B;
B["A"] = 1;
B["B"] = 2;
B["C"] = 3;
B["D"] = 3;
ASSERT_FALSE(A == B);
ASSERT_FALSE(B == A);
ASSERT_TRUE(A != B);
ASSERT_TRUE(B != A);
}
TEST_F(StringMapTest, NotEqualWithDifferentValues) {
StringMap<int> A;
A["A"] = 1;
A["B"] = 2;
A["C"] = 100;
A["D"] = 3;
StringMap<int> B;
B["A"] = 1;
B["B"] = 2;
B["C"] = 3;
B["D"] = 3;
ASSERT_FALSE(A == B);
ASSERT_FALSE(B == A);
ASSERT_TRUE(A != B);
ASSERT_TRUE(B != A);
}
struct Countable {
int &InstanceCount;
int Number;