[Support] Remove some #if __cplusplus > 201402L

This commit is contained in:
Fangrui Song 2022-08-11 17:35:02 +00:00
parent 99baa10f8f
commit 1ca5fee228
4 changed files with 0 additions and 16 deletions

View File

@ -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) {

View File

@ -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 @@ public:
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());

View File

@ -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) {

View File

@ -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\")",