21 #include "llvm/ADT/SmallVector.h" 22 #include "llvm/Support/FormattedStream.h" 23 #include "llvm/Support/raw_ostream.h" 26 using namespace clang;
35 auto checkerMgr = llvm::make_unique<CheckerManager>(context, opts);
39 for (
const auto &Fn : checkerRegistrationFns)
42 allCheckers.initializeManager(*checkerMgr, opts);
43 allCheckers.validateCheckerOptions(opts);
44 checkerMgr->finishedCheckerRegistration();
51 out <<
"OVERVIEW: Clang Static Analyzer Checkers List\n\n";
52 out <<
"USAGE: -analyzer-checker <CHECKER or PACKAGE,...>\n\n";
61 out <<
"OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n";
67 out <<
"OVERVIEW: Clang Static Analyzer -analyzer-config Option List\n\n";
68 out <<
"USAGE: clang -cc1 [CLANG_OPTIONS] -analyzer-config " 69 "<OPTION1=VALUE,OPTION2=VALUE,...>\n\n";
70 out <<
" clang -cc1 [CLANG_OPTIONS] -analyzer-config OPTION1=VALUE, " 71 "-analyzer-config OPTION2=VALUE, ...\n\n";
72 out <<
" clang [CLANG_OPTIONS] -Xclang -analyzer-config -Xclang" 73 "<OPTION1=VALUE,OPTION2=VALUE,...>\n\n";
74 out <<
" clang [CLANG_OPTIONS] -Xclang -analyzer-config -Xclang " 75 "OPTION1=VALUE, -Xclang -analyzer-config -Xclang " 76 "OPTION2=VALUE, ...\n\n";
77 out <<
"OPTIONS:\n\n";
79 using OptionAndDescriptionTy = std::pair<StringRef, std::string>;
80 OptionAndDescriptionTy PrintableOptions[] = {
81 #define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL) \ 84 llvm::Twine(llvm::Twine() + "(" + \ 85 (StringRef(#TYPE) == "StringRef" ? "string" : #TYPE ) + \ 87 " (default: " #DEFAULT_VAL ")").str() \ 90 #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \ 91 SHALLOW_VAL, DEEP_VAL) \ 94 llvm::Twine(llvm::Twine() + "(" + \ 95 (StringRef(#TYPE) == "StringRef" ? "string" : #TYPE ) + \ 97 " (default: " #SHALLOW_VAL " in shallow mode, " #DEEP_VAL \ 98 " in deep mode)").str() \ 100 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.def" 101 #undef ANALYZER_OPTION 102 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE 105 llvm::sort(PrintableOptions, [](
const OptionAndDescriptionTy &LHS,
106 const OptionAndDescriptionTy &RHS) {
107 return LHS.first < RHS.first;
110 constexpr
size_t MinLineWidth = 70;
111 constexpr
size_t PadForOpt = 2;
112 constexpr
size_t OptionWidth = 30;
113 constexpr
size_t PadForDesc = PadForOpt + OptionWidth;
114 static_assert(MinLineWidth > PadForDesc,
"MinLineWidth must be greater!");
116 llvm::formatted_raw_ostream FOut(out);
118 for (
const auto &Pair : PrintableOptions) {
119 FOut.PadToColumn(PadForOpt) << Pair.first;
122 if (FOut.getColumn() > PadForDesc)
125 FOut.PadToColumn(PadForDesc);
127 for (
char C : Pair.second) {
128 if (FOut.getColumn() > MinLineWidth && C ==
' ') {
130 FOut.PadToColumn(PadForDesc);
Manages a set of available checkers for running a static analysis.
void printList(raw_ostream &out, const AnalyzerOptions &opts) const
void printAnalyzerConfigList(raw_ostream &OS)
std::unique_ptr< CheckerManager > createCheckerManager(ASTContext &context, AnalyzerOptions &opts, ArrayRef< std::string > plugins, ArrayRef< std::function< void(CheckerRegistry &)>> checkerRegistrationFns, DiagnosticsEngine &diags)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void printCheckerHelp(raw_ostream &OS, ArrayRef< std::string > plugins, DiagnosticsEngine &diags)
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
void printEnabledCheckerList(raw_ostream &OS, ArrayRef< std::string > plugins, const AnalyzerOptions &opts, DiagnosticsEngine &diags)
Dataflow Directional Tag Classes.
Stores options for the analyzer from the command line.
void printHelp(raw_ostream &out, size_t maxNameChars=30) const
Prints the name and description of all checkers in this registry.