[llvm] 1ca5fee - [Support] Remove some #if __cplusplus > 201402L

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 10:35:07 PDT 2022


Author: Fangrui Song
Date: 2022-08-11T17:35:02Z
New Revision: 1ca5fee2285de6e81d52a38de5cfdbe3a7a79f74

URL: https://github.com/llvm/llvm-project/commit/1ca5fee2285de6e81d52a38de5cfdbe3a7a79f74
DIFF: https://github.com/llvm/llvm-project/commit/1ca5fee2285de6e81d52a38de5cfdbe3a7a79f74.diff

LOG: [Support] Remove some #if __cplusplus > 201402L

Added: 
    

Modified: 
    llvm/include/llvm/ADT/Twine.h
    llvm/include/llvm/Support/raw_ostream.h
    llvm/unittests/ADT/StringRefTest.cpp
    llvm/unittests/ADT/TwineTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/Twine.h b/llvm/include/llvm/ADT/Twine.h
index 6364a91454d31..ecd9d6df60ac6 100644
--- a/llvm/include/llvm/ADT/Twine.h
+++ b/llvm/include/llvm/ADT/Twine.h
@@ -15,9 +15,7 @@
 #include <cassert>
 #include <cstdint>
 #include <string>
-#if __cplusplus > 201402L
 #include <string_view>
-#endif
 
 namespace llvm {
 
@@ -287,7 +285,6 @@ namespace llvm {
       assert(isValid() && "Invalid twine!");
     }
 
-#if __cplusplus > 201402L
     /// Construct from an std::string_view by converting it to a pointer and
     /// length.  This handles string_views on a pure API basis, and avoids
     /// storing one (or a pointer to one) inside a Twine, which avoids problems
@@ -298,7 +295,6 @@ namespace llvm {
       LHS.ptrAndLength.length = Str.length();
       assert(isValid() && "Invalid twine!");
     }
-#endif
 
     /// Construct from a StringRef.
     /*implicit*/ Twine(const StringRef &Str) : LHSKind(PtrAndLengthKind) {

diff  --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
index b0f06ba4e223b..bdb737dcb24c4 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -22,9 +22,7 @@
 #include <cstdint>
 #include <cstring>
 #include <string>
-#if __cplusplus > 201402L
 #include <string_view>
-#endif
 #include <system_error>
 #include <type_traits>
 
@@ -237,11 +235,9 @@ class raw_ostream {
     return write(Str.data(), Str.length());
   }
 
-#if __cplusplus > 201402L
   raw_ostream &operator<<(const std::string_view &Str) {
     return write(Str.data(), Str.length());
   }
-#endif
 
   raw_ostream &operator<<(const SmallVectorImpl<char> &Str) {
     return write(Str.data(), Str.size());

diff  --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index ac734585b0711..25cd3cd23322d 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -59,16 +59,12 @@ TEST(StringRefTest, Construction) {
   EXPECT_EQ("hello", StringRef("hello"));
   EXPECT_EQ("hello", StringRef("hello world", 5));
   EXPECT_EQ("hello", StringRef(std::string("hello")));
-#if __cplusplus > 201402L
   EXPECT_EQ("hello", StringRef(std::string_view("hello")));
-#endif
 }
 
 TEST(StringRefTest, Conversion) {
   EXPECT_EQ("hello", std::string(StringRef("hello")));
-#if __cplusplus > 201402L
   EXPECT_EQ("hello", std::string_view(StringRef("hello")));
-#endif
 }
 
 TEST(StringRefTest, EmptyInitializerList) {

diff  --git a/llvm/unittests/ADT/TwineTest.cpp b/llvm/unittests/ADT/TwineTest.cpp
index 543b4507f27b1..bb7127659ee92 100644
--- a/llvm/unittests/ADT/TwineTest.cpp
+++ b/llvm/unittests/ADT/TwineTest.cpp
@@ -32,9 +32,7 @@ TEST(TwineTest, Construction) {
   EXPECT_EQ("hi", Twine(StringRef("hithere", 2)).str());
   EXPECT_EQ("hi", Twine(SmallString<4>("hi")).str());
   EXPECT_EQ("hi", Twine(formatv("{0}", "hi")).str());
-#if __cplusplus > 201402L
   EXPECT_EQ("hi", Twine(std::string_view("hi")).str());
-#endif
 }
 
 TEST(TwineTest, Numbers) {
@@ -76,10 +74,8 @@ TEST(TwineTest, Concat) {
             repr(Twine().concat(Twine(formatv("howdy")))));
   EXPECT_EQ("(Twine ptrAndLength:\"hey\" cstring:\"there\")",
             repr(Twine(SmallString<7>("hey")).concat(Twine("there"))));
-#if __cplusplus > 201402L
   EXPECT_EQ("(Twine ptrAndLength:\"hey\" cstring:\"there\")",
             repr(Twine(std::string_view("hey")).concat(Twine("there"))));
-#endif
 
   // Concatenation of unary ropes.
   EXPECT_EQ("(Twine cstring:\"a\" cstring:\"b\")", 


        


More information about the llvm-commits mailing list