[wpiutil] Upgrade to LLVM 17.0.1 (#5482)

This commit is contained in:
Tyler Veness
2023-09-21 19:54:33 -07:00
committed by GitHub
parent 07a0d22fe6
commit 1b6ec5a95d
82 changed files with 1697 additions and 901 deletions

View File

@@ -12,10 +12,12 @@
#include "wpi/DenseMap.h"
#include "wpi/DenseMapInfo.h"
#include "wpi/DenseMapInfoVariant.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <map>
#include <set>
#include <string_view>
#include <utility>
#include <variant>
@@ -126,6 +128,7 @@ TYPED_TEST(DenseMapTest, EmptyIntMapTest) {
// Lookup tests
EXPECT_FALSE(this->Map.count(this->getKey()));
EXPECT_FALSE(this->Map.contains(this->getKey()));
EXPECT_TRUE(this->Map.find(this->getKey()) == this->Map.end());
EXPECT_EQ(typename TypeParam::mapped_type(),
this->Map.lookup(this->getKey()));
@@ -157,11 +160,21 @@ TYPED_TEST(DenseMapTest, SingleEntryMapTest) {
// Lookup tests
EXPECT_TRUE(this->Map.count(this->getKey()));
EXPECT_TRUE(this->Map.contains(this->getKey()));
EXPECT_TRUE(this->Map.find(this->getKey()) == this->Map.begin());
EXPECT_EQ(this->getValue(), this->Map.lookup(this->getKey()));
EXPECT_EQ(this->getValue(), this->Map[this->getKey()]);
}
TYPED_TEST(DenseMapTest, AtTest) {
this->Map[this->getKey(0)] = this->getValue(0);
this->Map[this->getKey(1)] = this->getValue(1);
this->Map[this->getKey(2)] = this->getValue(2);
EXPECT_EQ(this->getValue(0), this->Map.at(this->getKey(0)));
EXPECT_EQ(this->getValue(1), this->Map.at(this->getKey(1)));
EXPECT_EQ(this->getValue(2), this->Map.at(this->getKey(2)));
}
// Test clear() method
TYPED_TEST(DenseMapTest, ClearTest) {
this->Map[this->getKey()] = this->getValue();
@@ -658,6 +671,10 @@ struct A {
struct B : public A {
using A::A;
};
struct AlwaysEqType {
bool operator==(const AlwaysEqType &RHS) const { return true; }
};
} // namespace
namespace wpi {
@@ -670,6 +687,16 @@ struct DenseMapInfo<T, std::enable_if_t<std::is_base_of_v<A, T>>> {
return LHS.value == RHS.value;
}
};
template <> struct DenseMapInfo<AlwaysEqType> {
using T = AlwaysEqType;
static inline T getEmptyKey() { return {}; }
static inline T getTombstoneKey() { return {}; }
static unsigned getHashValue(const T &Val) { return 0; }
static bool isEqual(const T &LHS, const T &RHS) {
return false;
}
};
} // namespace wpi
namespace {
@@ -693,16 +720,21 @@ TEST(DenseMapCustomTest, SFINAEMapInfo) {
}
TEST(DenseMapCustomTest, VariantSupport) {
using variant = std::variant<int, int>;
using variant = std::variant<int, int, AlwaysEqType>;
DenseMap<variant, int> Map;
variant Keys[] = {
variant(std::in_place_index<0>, 1),
variant(std::in_place_index<1>, 1),
variant(std::in_place_index<2>),
};
Map.try_emplace(Keys[0], 0);
Map.try_emplace(Keys[1], 1);
EXPECT_THAT(Map, testing::SizeIs(2));
EXPECT_NE(DenseMapInfo<variant>::getHashValue(Keys[0]),
DenseMapInfo<variant>::getHashValue(Keys[1]));
// Check that isEqual dispatches to isEqual of underlying type, and not to
// operator==.
EXPECT_FALSE(DenseMapInfo<variant>::isEqual(Keys[2], Keys[2]));
}
} // namespace