summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
diff options
context:
space:
mode:
authorKristof Umann <kristof.umann@ericsson.com>2019-05-23 20:47:28 +0000
committerKristof Umann <kristof.umann@ericsson.com>2019-05-23 20:47:28 +0000
commite8df27d9256b38ec1a2467a1b9c087b00ffd17cc (patch)
tree7b17d3776217690e58a62413e1e8d104d0b1c693 /clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
parentdab31924e9c790555f916d21e6575e7f1e1cd5b7 (diff)
downloadbcm5719-llvm-e8df27d9256b38ec1a2467a1b9c087b00ffd17cc.tar.gz
bcm5719-llvm-e8df27d9256b38ec1a2467a1b9c087b00ffd17cc.zip
[analyzer] Add a new frontend flag to display all checker options
Add the new frontend flag -analyzer-checker-option-help to display all checker/package options. Differential Revision: https://reviews.llvm.org/D57858 llvm-svn: 361552
Diffstat (limited to 'clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp51
1 files changed, 40 insertions, 11 deletions
diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
index d41ca0a8f32..d405933ca65 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -518,17 +518,8 @@ void CheckerRegistry::printCheckerWithDescList(raw_ostream &Out,
if (!AnOpts.ShowCheckerHelpHidden && Checker.IsHidden)
continue;
- Out.indent(InitialPad) << Checker.FullName;
-
- int Pad = OptionFieldWidth - Checker.FullName.size();
-
- // Break on long option names.
- if (Pad < 0) {
- Out << '\n';
- Pad = OptionFieldWidth + InitialPad;
- }
- Out.indent(Pad + 2) << Checker.Desc;
-
+ AnalyzerOptions::printFormattedEntry(Out, {Checker.FullName, Checker.Desc},
+ InitialPad, OptionFieldWidth);
Out << '\n';
}
}
@@ -540,3 +531,41 @@ void CheckerRegistry::printEnabledCheckerList(raw_ostream &Out) const {
for (const auto *i : EnabledCheckers)
Out << i->FullName << '\n';
}
+
+void CheckerRegistry::printCheckerOptionList(raw_ostream &Out) const {
+ Out << "OVERVIEW: Clang Static Analyzer Checker and Package Option List\n\n";
+ Out << "USAGE: -analyzer-config <OPTION1=VALUE,OPTION2=VALUE,...>\n\n";
+ Out << " -analyzer-config OPTION1=VALUE, -analyzer-config "
+ "OPTION2=VALUE, ...\n\n";
+ Out << "OPTIONS:\n\n";
+
+ std::multimap<StringRef, const CmdLineOption &> OptionMap;
+
+ for (const CheckerInfo &Checker : Checkers) {
+ for (const CmdLineOption &Option : Checker.CmdLineOptions) {
+ OptionMap.insert({Checker.FullName, Option});
+ }
+ }
+
+ for (const PackageInfo &Package : Packages) {
+ for (const CmdLineOption &Option : Package.CmdLineOptions) {
+ OptionMap.insert({Package.FullName, Option});
+ }
+ }
+
+ for (const std::pair<StringRef, const CmdLineOption &> &Entry : OptionMap) {
+ const CmdLineOption &Option = Entry.second;
+ std::string FullOption = (Entry.first + ":" + Option.OptionName).str();
+
+ std::string Desc =
+ ("(" + Option.OptionType + ") " + Option.Description + " (default: " +
+ (Option.DefaultValStr.empty() ? "\"\"" : Option.DefaultValStr) + ")")
+ .str();
+
+ AnalyzerOptions::printFormattedEntry(Out, {FullOption, Desc},
+ /*InitialPad*/ 2,
+ /*EntryWidth*/ 50,
+ /*MinLineWidth*/ 90);
+ Out << "\n\n";
+ }
+}
OpenPOWER on IntegriCloud