Update LLVM libraries to 14.0.6 (#4350)

The main noticeable change is the SmallString conversion operator to std::string is now explicit instead of implicit.
This commit is contained in:
Tyler Veness
2022-08-15 05:38:15 -07:00
committed by GitHub
parent c5db23f296
commit 0e0786331a
70 changed files with 1211 additions and 823 deletions

View File

@@ -23,7 +23,7 @@ TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
bool Success = convertUTF16ToUTF8String(Ref, Result);
EXPECT_TRUE(Success);
std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
EXPECT_EQ(Expected, Result.string());
EXPECT_EQ(Expected, std::string{Result});
}
TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
@@ -34,7 +34,7 @@ TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
bool Success = convertUTF16ToUTF8String(Ref, Result);
EXPECT_TRUE(Success);
std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
EXPECT_EQ(Expected, Result.string());
EXPECT_EQ(Expected, std::string{Result});
}
TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
@@ -60,7 +60,7 @@ TEST(ConvertUTFTest, Empty) {
SmallString<20> Result;
bool Success = convertUTF16ToUTF8String(span<const char>(), Result);
EXPECT_TRUE(Success);
EXPECT_TRUE(Result.string().empty());
EXPECT_TRUE(std::string{Result}.empty());
}
TEST(ConvertUTFTest, HasUTF16BOM) {
@@ -87,7 +87,7 @@ TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
bool Success = convertUTF16ToUTF8String(SrcRef, Result);
EXPECT_TRUE(Success);
std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
EXPECT_EQ(Expected, Result.string());
EXPECT_EQ(Expected, std::string{Result});
}
TEST(ConvertUTFTest, ConvertUTF8toWide) {
@@ -111,7 +111,7 @@ TEST(ConvertUTFTest, convertWideToUTF8) {
bool Success = convertWideToUTF8(Src, Result);
EXPECT_TRUE(Success);
std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
EXPECT_EQ(Expected, Result.string());
EXPECT_EQ(Expected, std::string{Result});
}
struct ConvertUTFResultContainer {

View File

@@ -634,4 +634,47 @@ TEST(DenseMapCustomTest, OpaquePointerKey) {
EXPECT_EQ(Map.find(K2), Map.end());
EXPECT_EQ(Map.find(K3), Map.end());
}
} // namespace
namespace {
struct A {
A(int value) : value(value) {}
int value;
};
struct B : public A {
using A::A;
};
} // namespace
namespace wpi {
template <typename T>
struct DenseMapInfo<T, std::enable_if_t<std::is_base_of<A, T>::value>> {
static inline T getEmptyKey() { return {static_cast<int>(~0)}; }
static inline T getTombstoneKey() { return {static_cast<int>(~0U - 1)}; }
static unsigned getHashValue(const T &Val) { return Val.value; }
static bool isEqual(const T &LHS, const T &RHS) {
return LHS.value == RHS.value;
}
};
} // namespace wpi
namespace {
TEST(DenseMapCustomTest, SFINAEMapInfo) {
// Test that we can use a pointer to an incomplete type as a DenseMap key.
// This is an important build time optimization, since many classes have
// DenseMap members.
DenseMap<B, int> Map;
B Keys[3] = {{0}, {1}, {2}};
Map.insert({Keys[0], 1});
Map.insert({Keys[1], 2});
Map.insert({Keys[2], 3});
EXPECT_EQ(Map.count(Keys[0]), 1u);
EXPECT_EQ(Map[Keys[0]], 1);
EXPECT_EQ(Map[Keys[1]], 2);
EXPECT_EQ(Map[Keys[2]], 3);
Map.clear();
EXPECT_EQ(Map.find(Keys[0]), Map.end());
EXPECT_EQ(Map.find(Keys[1]), Map.end());
EXPECT_EQ(Map.find(Keys[2]), Map.end());
}
} // namespace

View File

@@ -291,4 +291,23 @@ TEST(UniqueFunctionTest, IncompleteTypes) {
unique_function<Templated<Incomplete> *()> IncompleteResultPointer;
}
// Incomplete function returning an incomplete type
Incomplete incompleteFunction();
const Incomplete incompleteFunctionConst();
// Check that we can assign a callable to a unique_function when the
// callable return value is incomplete.
TEST(UniqueFunctionTest, IncompleteCallableType) {
unique_function<Incomplete()> IncompleteReturnInCallable{incompleteFunction};
unique_function<const Incomplete()> IncompleteReturnInCallableConst{
incompleteFunctionConst};
unique_function<const Incomplete()> IncompleteReturnInCallableConstConversion{
incompleteFunction};
}
// Define the incomplete function
class Incomplete {};
Incomplete incompleteFunction() { return {}; }
const Incomplete incompleteFunctionConst() { return {}; }
} // anonymous namespace

View File

@@ -313,6 +313,32 @@ TYPED_TEST(SmallVectorTest, ResizeShrinkTest) {
EXPECT_EQ(5, Constructable::getNumDestructorCalls());
}
// Truncate test.
TYPED_TEST(SmallVectorTest, TruncateTest) {
SCOPED_TRACE("TruncateTest");
this->theVector.reserve(3);
this->makeSequence(this->theVector, 1, 3);
this->theVector.truncate(1);
this->assertValuesInOrder(this->theVector, 1u, 1);
EXPECT_EQ(6, Constructable::getNumConstructorCalls());
EXPECT_EQ(5, Constructable::getNumDestructorCalls());
#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST
EXPECT_DEATH(this->theVector.truncate(2), "Cannot increase size");
#endif
this->theVector.truncate(1);
this->assertValuesInOrder(this->theVector, 1u, 1);
EXPECT_EQ(6, Constructable::getNumConstructorCalls());
EXPECT_EQ(5, Constructable::getNumDestructorCalls());
this->theVector.truncate(0);
this->assertEmpty(this->theVector);
EXPECT_EQ(6, Constructable::getNumConstructorCalls());
EXPECT_EQ(6, Constructable::getNumDestructorCalls());
}
// Resize bigger test.
TYPED_TEST(SmallVectorTest, ResizeGrowTest) {
SCOPED_TRACE("ResizeGrowTest");

View File

@@ -110,6 +110,13 @@ TEST_F(StringMapTest, ConstEmptyMapTest) {
EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end());
}
// initializer_list ctor test; also implicitly tests initializer_list and
// iterator overloads of insert().
TEST_F(StringMapTest, InitializerListCtor) {
testMap = StringMap<uint32_t>({{"key", 1}});
assertSingleItemMap();
}
// A map with a single entry.
TEST_F(StringMapTest, SingleEntryMapTest) {
testMap[testKey] = testValue;
@@ -300,7 +307,7 @@ TEST_F(StringMapTest, InsertOrAssignTest) {
EXPECT_EQ(0, try1.first->second.copy);
}
TEST_F(StringMapTest, IterMapKeys) {
TEST_F(StringMapTest, IterMapKeysSmallVector) {
StringMap<int> Map;
Map["A"] = 1;
Map["B"] = 2;