[llvm-branch-commits] [llvm] 4ea9a4a - Declare __builtin_strlen in StringRef.h as constexpr

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Feb 3 07:59:49 PST 2020


Author: Hans Wennborg
Date: 2020-02-03T16:59:37+01:00
New Revision: 4ea9a4aba4a7cfea0325022d50b97a9409026ab5

URL: https://github.com/llvm/llvm-project/commit/4ea9a4aba4a7cfea0325022d50b97a9409026ab5
DIFF: https://github.com/llvm/llvm-project/commit/4ea9a4aba4a7cfea0325022d50b97a9409026ab5.diff

LOG: Declare __builtin_strlen in StringRef.h as constexpr

Otherwise Visual Studio 2017 will complain about
llvm::StringRef::strlen not being constexpr:

  StringRef.h(80): error C3615: constexpr function 'llvm::StringRef::strLen' cannot result in a constant expression
  StringRef.h(84): note: failure was caused by call of undefined function or one not declared 'constexpr'

(cherry picked from commit b3d7d1061dc375bb5ea725e6597382fcd37f41d6)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 9bfaaccd953e..6d75cf8b04e7 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -24,7 +24,7 @@
 // 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 *);
+extern "C" constexpr size_t __builtin_strlen(const char *);
 #endif
 
 namespace llvm {


        


More information about the llvm-branch-commits mailing list