clang: lib/StaticAnalyzer/Core/CheckerRegistryData.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
11#include "llvm/ADT/Twine.h"
12#include
13
14using namespace clang;
15using namespace ento;
16
17
18
19
20
23}
24
25LLVM_DUMP_METHOD void
27
28
32}
33
35 switch (Kind) {
36 case StateFromCmdLine::State_Disabled:
37 return "Disabled";
38 case StateFromCmdLine::State_Enabled:
39 return "Enabled";
40 case StateFromCmdLine::State_Unspecified:
41 return "Unspecified";
42 }
43 llvm_unreachable("Unhandled StateFromCmdLine enum");
44}
45
47
49
50
52 << ")\n";
53 Out << " Options:\n";
55 Out << " ";
56 Option.dumpToStream(Out);
57 Out << '\n';
58 }
59 Out << " Dependencies:\n";
61 Out << " " << Dependency->FullName << '\n';
62 }
63 Out << " Weak dependencies:\n";
65 Out << " " << Dependency->FullName << '\n';
66 }
67}
68
70
73 Out << " Options:\n";
75 Out << " ";
76 Option.dumpToStream(Out);
77 Out << '\n';
78 }
79}
80
82
84
85 if (.FullName.starts_with(PackageName))
86 return false;
87
88
89 if (Checker.FullName.size() == PackageName.size())
90 return true;
91
92
94 return true;
95
96 return false;
97}
98
102
105
106
107
108
109 size_t Size = 1;
110 llvm::StringMap<size_t>::const_iterator PackageSize =
112
114 Size = PackageSize->getValue();
115
116 return {It, It + Size};
117}
118
119
120
121
124 size_t MaxNameChars) const {
125
126
127 Out << "CHECKERS:\n";
128
129
130 size_t OptionFieldWidth = 0;
132
133
134 size_t NameLength = Checker.FullName.size();
135 if (NameLength <= MaxNameChars)
136 OptionFieldWidth = std::max(OptionFieldWidth, NameLength);
137 }
138
139 const size_t InitialPad = 2;
140
142 StringRef Description) {
144 InitialPad, OptionFieldWidth);
145 Out << '\n';
146 };
147
149
150
151
152
153
154
158 continue;
159 }
160
161 if (Checker.FullName.starts_with("alpha")) {
164 ("(Enable only for development!) " + Checker.Desc).str());
165 continue;
166 }
167
170 }
171}
172
175 Out << i->FullName << '\n';
176}
177
179 raw_ostream &Out) const {
180 Out << "OVERVIEW: Clang Static Analyzer Checker and Package Option List\n\n";
181 Out << "USAGE: -analyzer-config <OPTION1=VALUE,OPTION2=VALUE,...>\n\n";
182 Out << " -analyzer-config OPTION1=VALUE, -analyzer-config "
183 "OPTION2=VALUE, ...\n\n";
184 Out << "OPTIONS:\n\n";
185
186
187
188 std::multimap<StringRef, const CmdLineOption &> OptionMap;
189
192 OptionMap.insert({Checker.FullName, Option});
193 }
194 }
195
197 for (const CmdLineOption &Option : Package.CmdLineOptions) {
198 OptionMap.insert({Package.FullName, Option});
199 }
200 }
201
202 auto Print = [](llvm::raw_ostream &Out, StringRef FullOption,
203 StringRef Desc) {
205 2,
206 50,
207 90);
208 Out << "\n\n";
209 };
210 for (const std::pair<const StringRef, const CmdLineOption &> &Entry :
211 OptionMap) {
213 std::string FullOption = (Entry.first + ":" + Option.OptionName).str();
214
215 std::string Desc =
218 .str();
219
220
221
222
223
226 Print(Out, FullOption, Desc);
227 continue;
228 }
229
231 Entry.first.starts_with("alpha")) {
233 Print(Out, FullOption,
234 llvm::Twine("(Enable only for development!) " + Desc).str());
235 continue;
236 }
237
239 Print(Out, FullOption, Desc);
240 }
241}
static constexpr char PackageSeparator
static bool isInPackage(const CheckerInfo &Checker, StringRef PackageName)
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Stores options for the analyzer from the command line.
unsigned ShowCheckerOptionDeveloperList
unsigned ShowCheckerHelpAlpha
unsigned ShowCheckerHelpDeveloper
unsigned ShowCheckerOptionList
static void printFormattedEntry(llvm::raw_ostream &Out, std::pair< StringRef, StringRef > EntryDescPair, size_t InitialPad, size_t EntryWidth, size_t MinLineWidth=0)
Convenience function for printing options or checkers and their description in a formatted manner.
unsigned ShowCheckerOptionAlphaList
std::conditional_t< std::is_const< CheckerOrPackageInfoList >::value, typename CheckerOrPackageInfoList::const_iterator, typename CheckerOrPackageInfoList::iterator > binaryFind(CheckerOrPackageInfoList &Collection, StringRef FullName)
llvm::iterator_range< CheckerInfoList::iterator > CheckerInfoListRange
The JSON file list parser is used to communicate input to InstallAPI.
ConstCheckerInfoList WeakDependencies
ConstCheckerInfoList Dependencies
CmdLineOptionList CmdLineOptions
LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const
LLVM_DUMP_METHOD void dump() const
CheckerInfoListRange getMutableCheckersForCmdLineArg(StringRef CmdLineArg)
void printCheckerOptionList(const AnalyzerOptions &AnOpts, raw_ostream &Out) const
CheckerInfoSet EnabledCheckers
void printCheckerWithDescList(const AnalyzerOptions &AnOpts, raw_ostream &Out, size_t MaxNameChars=30) const
Prints the name and description of all checkers in this registry.
void printEnabledCheckerList(raw_ostream &Out) const
llvm::StringMap< size_t > PackageSizes
Used for counting how many checkers belong to a certain package in the Checkers field.
Specifies a command line option.
StringRef DevelopmentStatus
LLVM_DUMP_METHOD void dump() const
LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const
CmdLineOptionList CmdLineOptions
LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const
LLVM_DUMP_METHOD void dump() const