17 #include "llvm/ADT/STLExtras.h" 18 #include "llvm/ADT/SetVector.h" 19 #include "llvm/ADT/StringMap.h" 20 #include "llvm/ADT/StringRef.h" 21 #include "llvm/Support/raw_ostream.h" 26 using namespace clang;
31 using CheckerInfoSet = llvm::SetVector<const CheckerRegistry::CheckerInfo *>;
39 StringRef packageName) {
41 if (!checker.
FullName.startswith(packageName))
45 if (checker.
FullName.size() == packageName.size())
56 const llvm::StringMap<size_t> &packageSizes,
60 auto end = checkers.cend();
61 auto i = std::lower_bound(checkers.cbegin(), end, packageInfo,
checkerNameLT);
77 llvm::StringMap<size_t>::const_iterator packageSize =
78 packageSizes.find(opt.
getName());
79 if (packageSize != packageSizes.end())
80 size = packageSize->getValue();
83 for (
auto checkEnd = i+size; i != checkEnd; ++i)
85 collected.insert(&*i);
87 collected.remove(&*i);
95 StringRef packageName, leafName;
97 while (!leafName.empty()) {
98 Packages[packageName] += 1;
114 for (
const auto *i :enabledCheckers) {
116 i->Initialize(checkerMgr);
122 for (
const auto &config : opts.
Config) {
123 size_t pos = config.getKey().find(
':');
124 if (pos == StringRef::npos)
127 bool hasChecker =
false;
128 StringRef checkerName = config.getKey().substr(0, pos);
129 for (
const auto &checker : Checkers) {
130 if (checker.FullName.startswith(checkerName) &&
131 (checker.FullName.size() == pos || checker.FullName[pos] ==
'.')) {
137 diags.
Report(diag::err_unknown_analyzer_checker) << checkerName;
142 size_t maxNameChars)
const {
150 out <<
"CHECKERS:\n";
153 size_t optionFieldWidth = 0;
154 for (
const auto &i : Checkers) {
157 size_t nameLength = i.FullName.size();
158 if (nameLength <= maxNameChars)
159 optionFieldWidth =
std::max(optionFieldWidth, nameLength);
162 const size_t initialPad = 2;
163 for (
const auto &i : Checkers) {
164 out.indent(initialPad) << i.FullName;
166 int pad = optionFieldWidth - i.FullName.size();
171 pad = optionFieldWidth + initialPad;
173 out.indent(pad + 2) << i.Desc;
188 for (
const auto *i : enabledCheckers)
189 out << i->FullName <<
'\n';
void validateCheckerOptions(const AnalyzerOptions &opts, DiagnosticsEngine &diags) const
Check if every option corresponds to a specific checker or package.
static void collectCheckers(const CheckerRegistry::CheckerInfoList &checkers, const llvm::StringMap< size_t > &packageSizes, CheckerOptInfo &opt, CheckerInfoSet &collected)
StringRef getName() const
static const char PackageSeparator
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Represents a request to include or exclude a checker or package from a specific analysis run...
void addChecker(InitializationFunction fn, StringRef fullName, StringRef desc)
Adds a checker to the registry.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
void setCurrentCheckName(CheckName name)
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
void printList(raw_ostream &out, SmallVectorImpl< CheckerOptInfo > &opts) const
ConfigTable Config
A key-value table of use-specified configuration values.
Dataflow Directional Tag Classes.
void(*)(CheckerManager &) InitializationFunction
Initialization functions perform any necessary setup for a checker.
static bool checkerNameLT(const CheckerRegistry::CheckerInfo &a, const CheckerRegistry::CheckerInfo &b)
std::vector< CheckerInfo > CheckerInfoList
llvm::SetVector< const CheckerRegistry::CheckerInfo * > CheckerInfoSet
void printHelp(raw_ostream &out, size_t maxNameChars=30) const
Prints the name and description of all checkers in this registry.
__DEVICE__ int max(int __a, int __b)
static bool isInPackage(const CheckerRegistry::CheckerInfo &checker, StringRef packageName)