From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:37:34 -0400 Subject: [PATCH 06/34] Explicitly use std:: --- llvm/include/llvm/ADT/DenseMap.h | 11 ++++++----- llvm/include/llvm/ADT/SmallSet.h | 2 +- llvm/lib/Support/ErrorHandling.cpp | 2 +- llvm/lib/Support/SmallPtrSet.cpp | 7 +++---- llvm/unittests/ADT/SmallPtrSetTest.cpp | 2 +- llvm/unittests/ADT/SmallSetTest.cpp | 10 +++++----- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index d207a515ef05425f924920a8d06d7c65d33e0909..37d8970209dcedf8840324a376ab27b3ba3bdf6a 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -17,8 +17,8 @@ #include "llvm/ADT/ADL.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/EpochTracker.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLForwardCompat.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/Support/AlignOf.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/MathExtras.h" @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -90,20 +91,20 @@ public: // Return an iterator to iterate over keys in the map. [[nodiscard]] inline auto keys() { - return map_range(*this, [](const BucketT &P) { return P.getFirst(); }); + return std::views::transform(*this, [](const BucketT &P) { return P.getFirst(); }); } // Return an iterator to iterate over values in the map. [[nodiscard]] inline auto values() { - return map_range(*this, [](const BucketT &P) { return P.getSecond(); }); + return std::views::transform(*this, [](const BucketT &P) { return P.getSecond(); }); } [[nodiscard]] inline auto keys() const { - return map_range(*this, [](const BucketT &P) { return P.getFirst(); }); + return std::views::transform(*this, [](const BucketT &P) { return P.getFirst(); }); } [[nodiscard]] inline auto values() const { - return map_range(*this, [](const BucketT &P) { return P.getSecond(); }); + return std::views::transform(*this, [](const BucketT &P) { return P.getSecond(); }); } [[nodiscard]] bool empty() const { return getNumEntries() == 0; } diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h index 3ca833f15eed37a4df2f8de37bcc4582d30581c4..2bc8ed01ff84671b5246a0dee42a76f086bb4687 100644 --- a/llvm/include/llvm/ADT/SmallSet.h +++ b/llvm/include/llvm/ADT/SmallSet.h @@ -287,7 +287,7 @@ template return false; // All elements in LHS must also be in RHS - return all_of(LHS, [&RHS](const T &E) { return RHS.count(E); }); + return std::all_of(LHS.begin(), LHS.end(), [&RHS](const T &E) { return RHS.count(E); }); } /// Inequality comparison for SmallSet. diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp index 7ab8a97bb85929615fc751a1eda1fee62004a26f..fcbc70535bf9869f72d001ec214d7046e975961a 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -279,7 +279,7 @@ std::error_code llvm::mapLastWindowsError() { // I'd rather not double the line count of the following. #define MAP_ERR_TO_COND(x, y) \ case x: \ - return make_error_code(errc::y) + return std::make_error_code(std::errc::y) std::error_code llvm::mapWindowsError(unsigned EV) { switch (EV) { diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp index e377dbf4a6999173ee0d04644ec5ee07e204d14d..9a8f99e4df164920d646909e614734894010047b 100644 --- a/llvm/lib/Support/SmallPtrSet.cpp +++ b/llvm/lib/Support/SmallPtrSet.cpp @@ -13,7 +13,6 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/DenseMapInfo.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/MemAlloc.h" #include @@ -191,7 +190,7 @@ void SmallPtrSetImplBase::copyHelper(const SmallPtrSetImplBase &RHS) { CurArraySize = RHS.CurArraySize; // Copy over the contents from the other set - llvm::copy(RHS.buckets(), CurArray); + std::ranges::copy(RHS.buckets(), CurArray); NumEntries = RHS.NumEntries; NumTombstones = RHS.NumTombstones; @@ -215,7 +214,7 @@ void SmallPtrSetImplBase::moveHelper(const void **SmallStorage, if (RHS.isSmall()) { // Copy a small RHS rather than moving. CurArray = SmallStorage; - llvm::copy(RHS.small_buckets(), CurArray); + std::ranges::copy(RHS.small_buckets(), CurArray); } else { CurArray = RHS.CurArray; RHS.CurArray = RHSSmallStorage; @@ -273,7 +272,7 @@ void SmallPtrSetImplBase::swap(const void **SmallStorage, SmallPtrSetImplBase &LargeSide = this->isSmall() ? RHS : *this; const void **LargeSideInlineStorage = this->isSmall() ? RHSSmallStorage : SmallStorage; - llvm::copy(SmallSide.small_buckets(), LargeSideInlineStorage); + std::ranges::copy(SmallSide.small_buckets(), LargeSideInlineStorage); std::swap(LargeSide.CurArraySize, SmallSide.CurArraySize); std::swap(LargeSide.NumEntries, SmallSide.NumEntries); std::swap(LargeSide.NumTombstones, SmallSide.NumTombstones); diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp index a25c07c08bbbba7b9edaa36adc5f9eaec14ea98d..bbe18dffdcf32d1bd71e756bccca74f1fcee5d0c 100644 --- a/llvm/unittests/ADT/SmallPtrSetTest.cpp +++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp @@ -261,7 +261,7 @@ TEST(SmallPtrSetTest, dereferenceAndIterate) { // Sort. We should hit the first element just once and the final element N // times. - llvm::sort(Found); + std::sort(std::begin(Found), std::end(Found)); for (auto F = std::begin(Found), E = std::end(Found); F != E; ++F) EXPECT_EQ(F - Found + 1, *F); } diff --git a/llvm/unittests/ADT/SmallSetTest.cpp b/llvm/unittests/ADT/SmallSetTest.cpp index 1d1e84ba7fcfd7aa528239a809fce5ede78618c1..7cb7e6c9d8482ed185845c6b09e4b91355d9b413 100644 --- a/llvm/unittests/ADT/SmallSetTest.cpp +++ b/llvm/unittests/ADT/SmallSetTest.cpp @@ -11,9 +11,9 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/SmallSet.h" -#include "llvm/ADT/STLExtras.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include using namespace llvm; @@ -186,7 +186,7 @@ TEST(SmallSetTest, IteratorInt) { std::vector V(s1.begin(), s1.end()); // Make sure the elements are in the expected order. - llvm::sort(V); + std::sort(V.begin(), V.end()); for (int i = 0; i < 3; i++) EXPECT_EQ(i, V[i]); @@ -197,7 +197,7 @@ TEST(SmallSetTest, IteratorInt) { V.assign(s1.begin(), s1.end()); // Make sure the elements are in the expected order. - llvm::sort(V); + std::sort(V.begin(), V.end()); for (int i = 0; i < 6; i++) EXPECT_EQ(i, V[i]); } @@ -212,7 +212,7 @@ TEST(SmallSetTest, IteratorString) { s1.insert("str 1"); std::vector V(s1.begin(), s1.end()); - llvm::sort(V); + std::sort(V.begin(), V.end()); EXPECT_EQ(2u, s1.size()); EXPECT_EQ("str 1", V[0]); EXPECT_EQ("str 2", V[1]); @@ -223,7 +223,7 @@ TEST(SmallSetTest, IteratorString) { V.assign(s1.begin(), s1.end()); // Make sure the elements are in the expected order. - llvm::sort(V); + std::sort(V.begin(), V.end()); EXPECT_EQ(4u, s1.size()); EXPECT_EQ("str 0", V[0]); EXPECT_EQ("str 1", V[1]);