[clang] 7a0ea12 - [clang][cli] Port analyzer flags to new option parsing system
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 19 06:43:12 PST 2020
Author: Jan Svoboda
Date: 2020-11-19T15:42:34+01:00
New Revision: 7a0ea120e2a1fffab71f9c8e3d5337899f7a42af
URL: https://github.com/llvm/llvm-project/commit/7a0ea120e2a1fffab71f9c8e3d5337899f7a42af
DIFF: https://github.com/llvm/llvm-project/commit/7a0ea120e2a1fffab71f9c8e3d5337899f7a42af.diff
LOG: [clang][cli] Port analyzer flags to new option parsing system
Depends on D83691
Reviewed By: dexonsmith
Original patch by Daniel Grumberg.
Differential Revision: https://reviews.llvm.org/D83693
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index f72e9af40547..d4aa4aa2f953 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3664,7 +3664,8 @@ def fno_padding_on_unsigned_fixed_point : Flag<["-"], "fno-padding-on-unsigned-f
//===----------------------------------------------------------------------===//
def analysis_UnoptimizedCFG : Flag<["-"], "unoptimized-cfg">,
- HelpText<"Generate unoptimized CFGs for all analyses">;
+ HelpText<"Generate unoptimized CFGs for all analyses">,
+ MarshallingInfoFlag<"AnalyzerOpts->UnoptimizedCFG">;
def analysis_CFGAddImplicitDtors : Flag<["-"], "cfg-add-implicit-dtors">,
HelpText<"Add C++ implicit destructors to CFGs for all analyses">;
@@ -3687,18 +3688,23 @@ def analyzer_purge : Separate<["-"], "analyzer-purge">,
def analyzer_purge_EQ : Joined<["-"], "analyzer-purge=">, Alias<analyzer_purge>;
def analyzer_opt_analyze_headers : Flag<["-"], "analyzer-opt-analyze-headers">,
- HelpText<"Force the static analyzer to analyze functions defined in header files">;
+ HelpText<"Force the static analyzer to analyze functions defined in header files">,
+ MarshallingInfoFlag<"AnalyzerOpts->AnalyzeAll">;
def analyzer_opt_analyze_nested_blocks : Flag<["-"], "analyzer-opt-analyze-nested-blocks">,
- HelpText<"Analyze the definitions of blocks in addition to functions">;
+ HelpText<"Analyze the definitions of blocks in addition to functions">,
+ MarshallingInfoFlag<"AnalyzerOpts->AnalyzeNestedBlocks">;
def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">,
- HelpText<"Emit verbose output about the analyzer's progress">;
+ HelpText<"Emit verbose output about the analyzer's progress">,
+ MarshallingInfoFlag<"AnalyzerOpts->AnalyzerDisplayProgress">;
def analyze_function : Separate<["-"], "analyze-function">,
HelpText<"Run analysis on specific function (for C++ include parameters in name)">;
def analyze_function_EQ : Joined<["-"], "analyze-function=">, Alias<analyze_function>;
def trim_egraph : Flag<["-"], "trim-egraph">,
- HelpText<"Only show error-related paths in the analysis graph">;
+ HelpText<"Only show error-related paths in the analysis graph">,
+ MarshallingInfoFlag<"AnalyzerOpts->TrimGraph">;
def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">,
- HelpText<"Display exploded graph using GraphViz">;
+ HelpText<"Display exploded graph using GraphViz">,
+ MarshallingInfoFlag<"AnalyzerOpts->visualizeExplodedGraphWithGraphViz">;
def analyzer_dump_egraph : Separate<["-"], "analyzer-dump-egraph">,
HelpText<"Dump exploded graph to the specified file">;
def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, Alias<analyzer_dump_egraph>;
@@ -3713,12 +3719,14 @@ def analyzer_inlining_mode : Separate<["-"], "analyzer-inlining-mode">,
def analyzer_inlining_mode_EQ : Joined<["-"], "analyzer-inlining-mode=">, Alias<analyzer_inlining_mode>;
def analyzer_disable_retry_exhausted : Flag<["-"], "analyzer-disable-retry-exhausted">,
- HelpText<"Do not re-analyze paths leading to exhausted nodes with a
diff erent strategy (may decrease code coverage)">;
+ HelpText<"Do not re-analyze paths leading to exhausted nodes with a
diff erent strategy (may decrease code coverage)">,
+ MarshallingInfoFlag<"AnalyzerOpts->NoRetryExhausted">;
def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">,
HelpText<"The maximum number of times the analyzer will go through a loop">;
def analyzer_stats : Flag<["-"], "analyzer-stats">,
- HelpText<"Print internal analyzer statistics.">;
+ HelpText<"Print internal analyzer statistics.">,
+ MarshallingInfoFlag<"AnalyzerOpts->PrintStats">;
def analyzer_checker : Separate<["-"], "analyzer-checker">,
HelpText<"Choose analyzer checkers to enable">,
@@ -3743,41 +3751,50 @@ def analyzer_disable_checker_EQ : Joined<["-"], "analyzer-disable-checker=">,
Alias<analyzer_disable_checker>;
def analyzer_disable_all_checks : Flag<["-"], "analyzer-disable-all-checks">,
- HelpText<"Disable all static analyzer checks">;
+ HelpText<"Disable all static analyzer checks">,
+ MarshallingInfoFlag<"AnalyzerOpts->DisableAllCheckers">;
def analyzer_checker_help : Flag<["-"], "analyzer-checker-help">,
- HelpText<"Display the list of analyzer checkers that are available">;
+ HelpText<"Display the list of analyzer checkers that are available">,
+ MarshallingInfoFlag<"AnalyzerOpts->ShowCheckerHelp">;
def analyzer_checker_help_alpha : Flag<["-"], "analyzer-checker-help-alpha">,
HelpText<"Display the list of in development analyzer checkers. These "
"are NOT considered safe, they are unstable and will emit incorrect "
- "reports. Enable ONLY FOR DEVELOPMENT purposes">;
+ "reports. Enable ONLY FOR DEVELOPMENT purposes">,
+ MarshallingInfoFlag<"AnalyzerOpts->ShowCheckerHelpAlpha">;
def analyzer_checker_help_developer : Flag<["-"], "analyzer-checker-help-developer">,
HelpText<"Display the list of developer-only checkers such as modeling "
- "and debug checkers">;
+ "and debug checkers">,
+ MarshallingInfoFlag<"AnalyzerOpts->ShowCheckerHelpDeveloper">;
def analyzer_config_help : Flag<["-"], "analyzer-config-help">,
HelpText<"Display the list of -analyzer-config options. These are meant for "
- "development purposes only!">;
+ "development purposes only!">,
+ MarshallingInfoFlag<"AnalyzerOpts->ShowConfigOptionsList">;
def analyzer_list_enabled_checkers : Flag<["-"], "analyzer-list-enabled-checkers">,
- HelpText<"Display the list of enabled analyzer checkers">;
+ HelpText<"Display the list of enabled analyzer checkers">,
+ MarshallingInfoFlag<"AnalyzerOpts->ShowEnabledCheckerList">;
def analyzer_config : Separate<["-"], "analyzer-config">,
HelpText<"Choose analyzer options to enable">;
def analyzer_checker_option_help : Flag<["-"], "analyzer-checker-option-help">,
- HelpText<"Display the list of checker and package options">;
+ HelpText<"Display the list of checker and package options">,
+ MarshallingInfoFlag<"AnalyzerOpts->ShowCheckerOptionList">;
def analyzer_checker_option_help_alpha : Flag<["-"], "analyzer-checker-option-help-alpha">,
HelpText<"Display the list of in development checker and package options. "
"These are NOT considered safe, they are unstable and will emit "
- "incorrect reports. Enable ONLY FOR DEVELOPMENT purposes">;
+ "incorrect reports. Enable ONLY FOR DEVELOPMENT purposes">,
+ MarshallingInfoFlag<"AnalyzerOpts->ShowCheckerOptionAlphaList">;
def analyzer_checker_option_help_developer : Flag<["-"], "analyzer-checker-option-help-developer">,
HelpText<"Display the list of checker and package options meant for "
- "development purposes only">;
+ "development purposes only">,
+ MarshallingInfoFlag<"AnalyzerOpts->ShowCheckerOptionDeveloperList">;
def analyzer_config_compatibility_mode : Separate<["-"], "analyzer-config-compatibility-mode">,
HelpText<"Don't emit errors on invalid analyzer-config inputs">;
@@ -3786,7 +3803,8 @@ def analyzer_config_compatibility_mode_EQ : Joined<["-"], "analyzer-config-compa
Alias<analyzer_config_compatibility_mode>;
def analyzer_werror : Flag<["-"], "analyzer-werror">,
- HelpText<"Emit analyzer results as errors rather than warnings">;
+ HelpText<"Emit analyzer results as errors rather than warnings">,
+ MarshallingInfoFlag<"AnalyzerOpts->AnalyzerWerror">;
//===----------------------------------------------------------------------===//
// Migrator Options
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index a0ed8178b9df..a68d3aab897e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -454,44 +454,19 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
}
}
- Opts.ShowCheckerHelp = Args.hasArg(OPT_analyzer_checker_help);
- Opts.ShowCheckerHelpAlpha = Args.hasArg(OPT_analyzer_checker_help_alpha);
- Opts.ShowCheckerHelpDeveloper =
- Args.hasArg(OPT_analyzer_checker_help_developer);
-
- Opts.ShowCheckerOptionList = Args.hasArg(OPT_analyzer_checker_option_help);
- Opts.ShowCheckerOptionAlphaList =
- Args.hasArg(OPT_analyzer_checker_option_help_alpha);
- Opts.ShowCheckerOptionDeveloperList =
- Args.hasArg(OPT_analyzer_checker_option_help_developer);
-
- Opts.ShowConfigOptionsList = Args.hasArg(OPT_analyzer_config_help);
- Opts.ShowEnabledCheckerList = Args.hasArg(OPT_analyzer_list_enabled_checkers);
Opts.ShouldEmitErrorsOnInvalidConfigValue =
/* negated */!llvm::StringSwitch<bool>(
Args.getLastArgValue(OPT_analyzer_config_compatibility_mode))
.Case("true", true)
.Case("false", false)
.Default(false);
- Opts.DisableAllCheckers = Args.hasArg(OPT_analyzer_disable_all_checks);
- Opts.visualizeExplodedGraphWithGraphViz =
- Args.hasArg(OPT_analyzer_viz_egraph_graphviz);
Opts.DumpExplodedGraphTo =
std::string(Args.getLastArgValue(OPT_analyzer_dump_egraph));
- Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
- Opts.AnalyzerWerror = Args.hasArg(OPT_analyzer_werror);
- Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
- Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
- Opts.AnalyzeNestedBlocks =
- Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
Opts.AnalyzeSpecificFunction =
std::string(Args.getLastArgValue(OPT_analyze_function));
- Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
- Opts.TrimGraph = Args.hasArg(OPT_trim_egraph);
Opts.maxBlockVisitOnPath =
getLastArgIntValue(Args, OPT_analyzer_max_loop, 4, Diags);
- Opts.PrintStats = Args.hasArg(OPT_analyzer_stats);
Opts.InlineMaxStackDepth =
getLastArgIntValue(Args, OPT_analyzer_inline_max_stack_depth,
Opts.InlineMaxStackDepth, Diags);
More information about the cfe-commits
mailing list