This revision was automatically updated to reflect the committed changes. Closed by commit rG53a4a2b45bb2: [clang] NFCI: Optimize storage and lookup of analyzer options (authored by jansvoboda11).
Changed prior to commit: https://reviews.llvm.org/D137258?vs=515455&id=515828#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137258/new/ https://reviews.llvm.org/D137258 Files: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ 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<llvm::StringLiteral> AnalyzerConfigCmdFlags = { + bool isUnknownAnalyzerConfig(llvm::StringRef Name) { + static std::vector<llvm::StringLiteral> AnalyzerConfigCmdFlags = []() { + // Create an array of all -analyzer-config command line options. + std::vector<llvm::StringLiteral> 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.
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ 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<llvm::StringLiteral> AnalyzerConfigCmdFlags = { + bool isUnknownAnalyzerConfig(llvm::StringRef Name) { + static std::vector<llvm::StringLiteral> AnalyzerConfigCmdFlags = []() { + // Create an array of all -analyzer-config command line options. + std::vector<llvm::StringLiteral> 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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits