[llvm] 72ebcf1 - [llvm][ADT] Fix formatting for files relevant to `StringMap`.
Wei Yi Tee via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 28 23:59:25 PDT 2022
Author: Wei Yi Tee
Date: 2022-08-29T06:57:29Z
New Revision: 72ebcf1a53a2fcf28aef96e606d030fa06749c55
URL: https://github.com/llvm/llvm-project/commit/72ebcf1a53a2fcf28aef96e606d030fa06749c55
DIFF: https://github.com/llvm/llvm-project/commit/72ebcf1a53a2fcf28aef96e606d030fa06749c55.diff
LOG: [llvm][ADT] Fix formatting for files relevant to `StringMap`.
Differential Revision: https://reviews.llvm.org/D132744
Added:
Modified:
llvm/include/llvm/ADT/StringMap.h
llvm/include/llvm/ADT/StringMapEntry.h
llvm/unittests/ADT/StringMapTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h
index 81f2626eea72c..eda82b4ef5255 100644
--- a/llvm/include/llvm/ADT/StringMap.h
+++ b/llvm/include/llvm/ADT/StringMap.h
@@ -326,7 +326,7 @@ class StringMap : public StringMapImpl,
/// if and only if the insertion takes place, and the iterator component of
/// the pair points to the element with key equivalent to the key of the pair.
template <typename... ArgsTy>
- std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&... Args) {
+ std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&...Args) {
unsigned BucketNo = LookupBucketFor(Key);
StringMapEntryBase *&Bucket = TheTable[BucketNo];
if (Bucket && Bucket != getTombstoneVal())
diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h
index 6e13c8618c851..d580cdcedc1b1 100644
--- a/llvm/include/llvm/ADT/StringMapEntry.h
+++ b/llvm/include/llvm/ADT/StringMapEntry.h
@@ -17,8 +17,8 @@
#define LLVM_ADT_STRINGMAPENTRY_H
#include "llvm/ADT/None.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/StringRef.h"
namespace llvm {
@@ -74,7 +74,7 @@ class StringMapEntryStorage : public StringMapEntryBase {
explicit StringMapEntryStorage(size_t keyLength)
: StringMapEntryBase(keyLength), second() {}
template <typename... InitTy>
- StringMapEntryStorage(size_t keyLength, InitTy &&... initVals)
+ StringMapEntryStorage(size_t keyLength, InitTy &&...initVals)
: StringMapEntryBase(keyLength),
second(std::forward<InitTy>(initVals)...) {}
StringMapEntryStorage(StringMapEntryStorage &e) = delete;
@@ -121,7 +121,7 @@ class StringMapEntry final : public StringMapEntryStorage<ValueTy> {
/// \p InitiVals.
template <typename AllocatorTy, typename... InitTy>
static StringMapEntry *Create(StringRef key, AllocatorTy &allocator,
- InitTy &&... initVals) {
+ InitTy &&...initVals) {
return new (StringMapEntryBase::allocateWithKey(
sizeof(StringMapEntry), alignof(StringMapEntry), key, allocator))
StringMapEntry(key.size(), std::forward<InitTy>(initVals)...);
diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
index 1eac07bcfb832..e5dae25c44083 100644
--- a/llvm/unittests/ADT/StringMapTest.cpp
+++ b/llvm/unittests/ADT/StringMapTest.cpp
@@ -28,7 +28,7 @@ class StringMapTest : public testing::Test {
static const char testKey[];
static const uint32_t testValue;
- static const char* testKeyFirst;
+ static const char *testKeyFirst;
static size_t testKeyLength;
static const std::string testKeyStr;
@@ -45,7 +45,7 @@ class StringMapTest : public testing::Test {
EXPECT_EQ(0u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
EXPECT_EQ(0u, testMap.count(testKeyStr));
EXPECT_TRUE(testMap.find(testKey) == testMap.end());
- EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
+ EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
testMap.end());
EXPECT_TRUE(testMap.find(testKeyStr) == testMap.end());
}
@@ -68,7 +68,7 @@ class StringMapTest : public testing::Test {
EXPECT_EQ(1u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
EXPECT_EQ(1u, testMap.count(testKeyStr));
EXPECT_TRUE(testMap.find(testKey) == testMap.begin());
- EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
+ EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
testMap.begin());
EXPECT_TRUE(testMap.find(testKeyStr) == testMap.begin());
}
@@ -76,7 +76,7 @@ class StringMapTest : public testing::Test {
const char StringMapTest::testKey[] = "key";
const uint32_t StringMapTest::testValue = 1u;
-const char* StringMapTest::testKeyFirst = testKey;
+const char *StringMapTest::testKeyFirst = testKey;
size_t StringMapTest::testKeyLength = sizeof(testKey) - 1;
const std::string StringMapTest::testKeyStr(testKey);
@@ -91,13 +91,11 @@ struct CountCopyAndMove {
};
// Empty map tests.
-TEST_F(StringMapTest, EmptyMapTest) {
- assertEmptyMap();
-}
+TEST_F(StringMapTest, EmptyMapTest) { assertEmptyMap(); }
// Constant map tests.
TEST_F(StringMapTest, ConstEmptyMapTest) {
- const StringMap<uint32_t>& constTestMap = testMap;
+ const StringMap<uint32_t> &constTestMap = testMap;
// Size tests
EXPECT_EQ(0u, constTestMap.size());
@@ -220,8 +218,8 @@ TEST_F(StringMapTest, IterationTest) {
}
// Iterate over all numbers and mark each one found.
- for (StringMap<uint32_t>::iterator it = testMap.begin();
- it != testMap.end(); ++it) {
+ for (StringMap<uint32_t>::iterator it = testMap.begin(); it != testMap.end();
+ ++it) {
std::stringstream ss;
ss << "key_" << it->second;
ASSERT_STREQ(ss.str().c_str(), it->first().data());
@@ -248,10 +246,8 @@ TEST_F(StringMapTest, StringMapEntryTest) {
// Test insert() method.
TEST_F(StringMapTest, InsertTest) {
SCOPED_TRACE("InsertTest");
- testMap.insert(
- StringMap<uint32_t>::value_type::Create(
- StringRef(testKeyFirst, testKeyLength),
- testMap.getAllocator(), 1u));
+ testMap.insert(StringMap<uint32_t>::value_type::Create(
+ StringRef(testKeyFirst, testKeyLength), testMap.getAllocator(), 1u));
assertSingleItemMap();
}
@@ -286,7 +282,7 @@ TEST_F(StringMapTest, InsertRehashingPairTest) {
EXPECT_EQ(0u, t.getNumBuckets());
StringMap<uint32_t>::iterator It =
- t.insert(std::make_pair("abcdef", 42)).first;
+ t.insert(std::make_pair("abcdef", 42)).first;
EXPECT_EQ(16u, t.getNumBuckets());
EXPECT_EQ("abcdef", It->first());
EXPECT_EQ(42u, It->second);
@@ -358,13 +354,13 @@ TEST_F(StringMapTest, NonDefaultConstructable) {
struct Immovable {
Immovable() {}
- Immovable(Immovable&&) = delete; // will disable the other special members
+ Immovable(Immovable &&) = delete; // will disable the other special members
};
struct MoveOnly {
int i;
MoveOnly(int i) : i(i) {}
- MoveOnly(const Immovable&) : i(0) {}
+ MoveOnly(const Immovable &) : i(0) {}
MoveOnly(MoveOnly &&RHS) : i(RHS.i) {}
MoveOnly &operator=(MoveOnly &&RHS) {
i = RHS.i;
@@ -590,7 +586,7 @@ struct NonMoveableNonCopyableType {
NonMoveableNonCopyableType(const NonMoveableNonCopyableType &) = delete;
NonMoveableNonCopyableType(NonMoveableNonCopyableType &&) = delete;
};
-}
+} // namespace
// Test that we can "emplace" an element in the map without involving map/move
TEST(StringMapCustomTest, EmplaceTest) {
More information about the llvm-commits
mailing list