Skip to content

Commit 60641f9

Browse files
d0khaoNoQ
authored andcommitted
[StaticAnalyzer] Use llvm::StringLiteral instead of StringRef in few places
StringRef's constexpr constructor seems to be extremely slow in MSVC 2017, so don't use it for generated tables. Should make PR43369 a bit better, no functionality change. llvm-svn: 372386 (cherry picked from commit 8599ffa)
1 parent 25cbd18 commit 60641f9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,13 @@ class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
278278

279279
// Create an array of all -analyzer-config command line options. Sort it in
280280
// the constructor.
281-
std::vector<StringRef> AnalyzerConfigCmdFlags = {
281+
std::vector<llvm::StringLiteral> AnalyzerConfigCmdFlags = {
282282
#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \
283283
SHALLOW_VAL, DEEP_VAL) \
284284
ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL)
285285

286286
#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL) \
287-
CMDFLAG,
287+
llvm::StringLiteral(CMDFLAG),
288288

289289
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
290290
#undef ANALYZER_OPTION
@@ -415,9 +415,10 @@ inline UserModeKind AnalyzerOptions::getUserMode() const {
415415

416416
inline std::vector<StringRef>
417417
AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental) {
418-
static const StringRef StaticAnalyzerCheckerNames[] = {
418+
static constexpr llvm::StringLiteral StaticAnalyzerCheckerNames[] = {
419419
#define GET_CHECKERS
420-
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) FULLNAME,
420+
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \
421+
llvm::StringLiteral(FULLNAME),
421422
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
422423
#undef CHECKER
423424
#undef GET_CHECKERS
@@ -433,9 +434,9 @@ AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental) {
433434

434435
inline std::vector<StringRef>
435436
AnalyzerOptions::getRegisteredPackages(bool IncludeExperimental) {
436-
static const StringRef StaticAnalyzerPackageNames[] = {
437+
static constexpr llvm::StringLiteral StaticAnalyzerPackageNames[] = {
437438
#define GET_PACKAGES
438-
#define PACKAGE(FULLNAME) FULLNAME,
439+
#define PACKAGE(FULLNAME) llvm::StringLiteral(FULLNAME),
439440
#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
440441
#undef PACKAGE
441442
#undef GET_PACKAGES

0 commit comments

Comments
 (0)