Commit ff837aa6 authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Actually, don't try to use __builtin_strlen in StringRef.h before VS 2019

The fix in b3d7d106 compiled nicely,
but didn't link because at least the VS 2017 version I use doesn't
have the builtin yet. Instead, make use of the builtin with MSVC
conditional on VS 2019 or later.
parent ad7b908b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
// Declare the __builtin_strlen intrinsic for MSVC so it can be used in
// constexpr context.
#if defined(_MSC_VER)
extern "C" constexpr size_t __builtin_strlen(const char *);
extern "C" size_t __builtin_strlen(const char *);
#endif

namespace llvm {
@@ -80,7 +80,8 @@ namespace llvm {
    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)
#elif __has_builtin(__builtin_strlen) || defined(__GNUC__) || \
    (defined(_MSC_VER) && _MSC_VER >= 1920)
      return __builtin_strlen(Str);
#else
      const char *Begin = Str;