diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h --- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -260,9 +260,10 @@ #undef ANALYZER_OPTION #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE - // Create an array of all -analyzer-config command line options. Sort it in - // the constructor. - std::vector AnalyzerConfigCmdFlags = { + bool isUnknownAnalyzerConfig(llvm::StringRef Name) { + static std::vector AnalyzerConfigCmdFlags = []() { + // Create an array of all -analyzer-config command line options. + std::vector AnalyzerConfigCmdFlags = { #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \ SHALLOW_VAL, DEEP_VAL) \ ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL) @@ -273,10 +274,11 @@ #include "clang/StaticAnalyzer/Core/AnalyzerOptions.def" #undef ANALYZER_OPTION #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE - }; - - bool isUnknownAnalyzerConfig(StringRef Name) const { - assert(llvm::is_sorted(AnalyzerConfigCmdFlags)); + }; + // FIXME: Sort this at compile-time when we get constexpr sort (C++20). + llvm::sort(AnalyzerConfigCmdFlags); + return AnalyzerConfigCmdFlags; + }(); return !std::binary_search(AnalyzerConfigCmdFlags.begin(), AnalyzerConfigCmdFlags.end(), Name); @@ -292,9 +294,7 @@ AnalyzerDisplayProgress(false), eagerlyAssumeBinOpBifurcation(false), TrimGraph(false), visualizeExplodedGraphWithGraphViz(false), UnoptimizedCFG(false), PrintStats(false), NoRetryExhausted(false), - AnalyzerWerror(false) { - llvm::sort(AnalyzerConfigCmdFlags); - } + AnalyzerWerror(false) {} /// Interprets an option's string value as a boolean. The "true" string is /// interpreted as true and the "false" string is interpreted as false.