aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2022-08-08 12:54:50 +0200
committerBenjamin Kramer <benny.kra@googlemail.com>2022-08-08 12:59:23 +0200
commitb4e9977fc18405d4a11cbaf1975bcadbf75920b8 (patch)
tree13569612e77eb3473688fc5221b7324007cec4e0
parente5e93b6130bde96d7e14851e218c5bf055f8a834 (diff)
Remove C++17 #ifdefs around the implicit conversion between StringRef and string_viewlinaro-local/ci/tcwg_kernel/llvm-master-arm-stable-allnoconfig
This is no longer needed as LLVM is built with C++17 now. Also drop the explicit conversion to std::string as the implicit conversion to std::string_view gets picked first anyways.
-rw-r--r--llvm/include/llvm/ADT/StringRef.h31
1 files changed, 1 insertions, 30 deletions
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 1ba92038dd75..1f7f91260751 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -19,18 +19,10 @@
#include <cstring>
#include <limits>
#include <string>
-#if __cplusplus > 201402L
#include <string_view>
-#endif
#include <type_traits>
#include <utility>
-// Declare the __builtin_strlen intrinsic for MSVC so it can be used in
-// constexpr context.
-#if defined(_MSC_VER)
-extern "C" size_t __builtin_strlen(const char *);
-#endif
-
namespace llvm {
class APInt;
@@ -77,21 +69,6 @@ namespace llvm {
return ::memcmp(Lhs,Rhs,Length);
}
- // Constexpr version of std::strlen.
- static constexpr size_t strLen(const char *Str) {
-#if __cplusplus > 201402L
- return std::char_traits<char>::length(Str);
-#elif __has_builtin(__builtin_strlen) || defined(__GNUC__) || \
- (defined(_MSC_VER) && _MSC_VER >= 1916)
- return __builtin_strlen(Str);
-#else
- const char *Begin = Str;
- while (*Str != '\0')
- ++Str;
- return Str - Begin;
-#endif
- }
-
public:
/// @name Constructors
/// @{
@@ -105,7 +82,7 @@ namespace llvm {
/// Construct a string ref from a cstring.
/*implicit*/ constexpr StringRef(const char *Str)
- : Data(Str), Length(Str ? strLen(Str) : 0) {}
+ : Data(Str), Length(Str ? std::char_traits<char>::length(Str) : 0) {}
/// Construct a string ref from a pointer and length.
/*implicit*/ constexpr StringRef(const char *data, size_t length)
@@ -115,11 +92,9 @@ namespace llvm {
/*implicit*/ StringRef(const std::string &Str)
: Data(Str.data()), Length(Str.length()) {}
-#if __cplusplus > 201402L
/// Construct a string ref from an std::string_view.
/*implicit*/ constexpr StringRef(std::string_view Str)
: Data(Str.data()), Length(Str.size()) {}
-#endif
/// @}
/// @name Iterators
@@ -261,13 +236,9 @@ namespace llvm {
/// @name Type Conversions
/// @{
- explicit operator std::string() const { return str(); }
-
-#if __cplusplus > 201402L
operator std::string_view() const {
return std::string_view(data(), size());
}
-#endif
/// @}
/// @name String Predicates