steakhal created this revision. steakhal added reviewers: NoQ, martong. Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun. Herald added a reviewer: Szelethus. Herald added a project: All. steakhal requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
I'm trying to remove unused options from the `Analyses.def` file, then merge the rest of the useful options into the `AnalyzerOptions.def`. Then make sure one can set these by an `-analyzer-config XXX=YYY` style flag. Then surface the `-analyzer-config` to the `clang` frontend; After all of this, we can pursue the tablegen approach described https://discourse.llvm.org/t/rfc-tablegen-clang-static-analyzer-engine-options-for-better-documentation/61488 In this patch, I'm proposing flag deprecations. We should support deprecated analyzer flags for at least one release. In this case I'm planning to drop this flag in `clang-17`. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D126215 Files: clang/docs/ReleaseNotes.rst clang/include/clang/Driver/Options.td clang/include/clang/StaticAnalyzer/Core/Analyses.def clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h clang/lib/Frontend/CompilerInvocation.cpp clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -171,13 +171,7 @@ } // Create the analyzer component creators. - switch (Opts->AnalysisStoreOpt) { - default: - llvm_unreachable("Unknown store manager."); -#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATEFN) \ - case NAME##Model: CreateStoreMgr = CREATEFN; break; -#include "clang/StaticAnalyzer/Core/Analyses.def" - } + CreateStoreMgr = &CreateRegionStoreManager; switch (Opts->AnalysisConstraintsOpt) { default: Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -816,18 +816,6 @@ #include "clang/Driver/Options.inc" #undef ANALYZER_OPTION_WITH_MARSHALLING - if (Opts.AnalysisStoreOpt != RegionStoreModel) { - switch (Opts.AnalysisStoreOpt) { -#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) \ - case NAME##Model: \ - GenerateArg(Args, OPT_analyzer_store, CMDFLAG, SA); \ - break; -#include "clang/StaticAnalyzer/Core/Analyses.def" - default: - llvm_unreachable("Tried to generate unknown analysis store."); - } - } - if (Opts.AnalysisConstraintsOpt != RangeConstraintsModel) { switch (Opts.AnalysisConstraintsOpt) { #define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) \ @@ -915,21 +903,6 @@ #include "clang/Driver/Options.inc" #undef ANALYZER_OPTION_WITH_MARSHALLING - if (Arg *A = Args.getLastArg(OPT_analyzer_store)) { - StringRef Name = A->getValue(); - AnalysisStores Value = llvm::StringSwitch<AnalysisStores>(Name) -#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) \ - .Case(CMDFLAG, NAME##Model) -#include "clang/StaticAnalyzer/Core/Analyses.def" - .Default(NumStores); - if (Value == NumStores) { - Diags.Report(diag::err_drv_invalid_value) - << A->getAsString(Args) << Name; - } else { - Opts.AnalysisStoreOpt = Value; - } - } - if (Arg *A = Args.getLastArg(OPT_analyzer_constraints)) { StringRef Name = A->getValue(); AnalysisConstraints Value = llvm::StringSwitch<AnalysisConstraints>(Name) Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h =================================================================== --- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -40,13 +40,6 @@ NumAnalyses }; -/// AnalysisStores - Set of available analysis store models. -enum AnalysisStores { -#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) NAME##Model, -#include "clang/StaticAnalyzer/Core/Analyses.def" -NumStores -}; - /// AnalysisConstraints - Set of available constraint models. enum AnalysisConstraints { #define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) NAME##Model, @@ -207,7 +200,6 @@ /// A key-value table of use-specified configuration values. // TODO: This shouldn't be public. ConfigTable Config; - AnalysisStores AnalysisStoreOpt = RegionStoreModel; AnalysisConstraints AnalysisConstraintsOpt = RangeConstraintsModel; AnalysisDiagClients AnalysisDiagOpt = PD_HTML; AnalysisPurgeMode AnalysisPurgeOpt = PurgeStmt; Index: clang/include/clang/StaticAnalyzer/Core/Analyses.def =================================================================== --- clang/include/clang/StaticAnalyzer/Core/Analyses.def +++ clang/include/clang/StaticAnalyzer/Core/Analyses.def @@ -10,13 +10,6 @@ // //===----------------------------------------------------------------------===// -#ifndef ANALYSIS_STORE -#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) -#endif - -ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store", - CreateRegionStoreManager) - #ifndef ANALYSIS_CONSTRAINTS #define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) #endif @@ -94,7 +87,6 @@ NoRedundancy, "noredundancy", "Do not analyze a function which has been previously inlined") -#undef ANALYSIS_STORE #undef ANALYSIS_CONSTRAINTS #undef ANALYSIS_DIAGNOSTICS #undef ANALYSIS_PURGE Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -4966,8 +4966,9 @@ def analysis_CFGAddImplicitDtors : Flag<["-"], "cfg-add-implicit-dtors">, HelpText<"Add C++ implicit destructors to CFGs for all analyses">; +// We should remove this option in clang-17 release. def analyzer_store : Separate<["-"], "analyzer-store">, - HelpText<"Source Code Analysis - Abstract Memory Store Models">; + HelpText<"Source Code Analysis - Abstract Memory Store Models [DEPRECATED]">; def analyzer_store_EQ : Joined<["-"], "analyzer-store=">, Alias<analyzer_store>; def analyzer_constraints : Separate<["-"], "analyzer-constraints">, Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -506,6 +506,9 @@ `strcmp``, ``strncmp``, ``strcpy``, ``strlen``, ``strsep`` and many more. Although this checker currently is in list of alpha checkers due to a false positive. +- Deprecate ``-analyzer-store region`` analyzer flag. This flag is still + accepted, but ``clang-17`` will reject this flag. + .. _release-notes-ubsan: Undefined Behavior Sanitizer (UBSan)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits