forked from OSchip/llvm-project
Use __builtin_strlen in constexpr StringRef ctor with MSVC
MSVC supports it. Fixes the major MSVC compile time regression introduced in r369961. Now clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp compiles in 18s instead of 7+ minutes. Fixes PR43369
This commit is contained in:
parent
feab0334f5
commit
6c89392592
|
@ -21,6 +21,12 @@
|
|||
#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;
|
||||
|
@ -71,7 +77,7 @@ 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__)
|
||||
#elif __has_builtin(__builtin_strlen) || defined(__GNUC__) || defined(_MSC_VER)
|
||||
return __builtin_strlen(Str);
|
||||
#else
|
||||
const char *Begin = Str;
|
||||
|
|
Loading…
Reference in New Issue