[PATCH] D76997: Fix StringRef::strLen in windows with clang++ C++17

Isuru Fernando via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 28 14:32:20 PDT 2020


isuruf created this revision.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.

This was found when compiling f18 using clang++ on windows.
f18 requires C++17 standard, but char_traits::length is not
a constexpr as required by the C++17 standard.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76997

Files:
  llvm/include/llvm/ADT/StringRef.h


Index: llvm/include/llvm/ADT/StringRef.h
===================================================================
--- llvm/include/llvm/ADT/StringRef.h
+++ llvm/include/llvm/ADT/StringRef.h
@@ -78,7 +78,7 @@
 
     // Constexpr version of std::strlen.
     static constexpr size_t strLen(const char *Str) {
-#if __cplusplus > 201402L
+#if __cplusplus > 201402L && !defined(_MSC_VER)
       return std::char_traits<char>::length(Str);
 #elif __has_builtin(__builtin_strlen) || defined(__GNUC__) || \
     (defined(_MSC_VER) && _MSC_VER >= 1916)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76997.253378.patch
Type: text/x-patch
Size: 539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200328/a02119eb/attachment-0001.bin>


More information about the llvm-commits mailing list