[cfe-commits] r128511 - in /cfe/trunk/lib/StaticAnalyzer: Checkers/ClangSACheckerProvider.cpp Checkers/ClangSACheckers.h Frontend/CheckerRegistration.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Mar 29 16:57:38 PDT 2011
Author: akirtzidis
Date: Tue Mar 29 18:57:38 2011
New Revision: 128511
URL: http://llvm.org/viewvc/llvm-project?rev=128511&view=rev
Log:
[analyzer] For -analyzer-checker-help show all the info about groups, packages, and which packages/checkers are hidden.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp?rev=128511&r1=128510&r2=128511&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp Tue Mar 29 18:57:38 2011
@@ -45,17 +45,54 @@
const char *FullName;
void (*RegFunc)(CheckerManager &mgr);
const char *HelpText;
+ int GroupIndex;
bool Hidden;
};
+struct StaticPackageInfoRec {
+ const char *FullName;
+ int GroupIndex;
+ bool Hidden;
+};
+
+struct StaticGroupInfoRec {
+ const char *FullName;
+};
+
} // end anonymous namespace.
+static const StaticPackageInfoRec StaticPackageInfo[] = {
+#define GET_PACKAGES
+#define PACKAGE(FULLNAME, GROUPINDEX, HIDDEN) \
+ { FULLNAME, GROUPINDEX, HIDDEN },
+#include "Checkers.inc"
+ { 0, -1, 0 }
+#undef PACKAGE
+#undef GET_PACKAGES
+};
+
+static const unsigned NumPackages = sizeof(StaticPackageInfo)
+ / sizeof(StaticPackageInfoRec) - 1;
+
+static const StaticGroupInfoRec StaticGroupInfo[] = {
+#define GET_GROUPS
+#define GROUP(FULLNAME) \
+ { FULLNAME },
+#include "Checkers.inc"
+ { 0 }
+#undef GROUP
+#undef GET_GROUPS
+};
+
+static const unsigned NumGroups = sizeof(StaticGroupInfo)
+ / sizeof(StaticGroupInfoRec) - 1;
+
static const StaticCheckerInfoRec StaticCheckerInfo[] = {
#define GET_CHECKERS
-#define CHECKER(FULLNAME,CLASS,DESCFILE,HELPTEXT,HIDDEN) \
- { FULLNAME, register##CLASS, HELPTEXT, HIDDEN },
+#define CHECKER(FULLNAME,CLASS,DESCFILE,HELPTEXT,GROUPINDEX,HIDDEN) \
+ { FULLNAME, register##CLASS, HELPTEXT, GROUPINDEX, HIDDEN },
#include "Checkers.inc"
- { 0, 0, 0, 0}
+ { 0, 0, 0, -1, 0}
#undef CHECKER
#undef GET_CHECKERS
};
@@ -144,6 +181,48 @@
}
}
+//===----------------------------------------------------------------------===//
+// Printing Help.
+//===----------------------------------------------------------------------===//
+
+static void printPackageOption(llvm::raw_ostream &OS) {
+ // Find the maximum option length.
+ unsigned OptionFieldWidth = 0;
+ for (unsigned i = 0; i != NumPackages; ++i) {
+ // Limit the amount of padding we are willing to give up for alignment.
+ unsigned Length = strlen(StaticPackageInfo[i].FullName);
+ if (Length <= 30)
+ OptionFieldWidth = std::max(OptionFieldWidth, Length);
+ }
+
+ const unsigned InitialPad = 2;
+ for (unsigned i = 0; i != NumPackages; ++i) {
+ const StaticPackageInfoRec &package = StaticPackageInfo[i];
+ const std::string &Option = package.FullName;
+ int Pad = OptionFieldWidth - int(Option.size());
+ OS.indent(InitialPad) << Option;
+
+ if (package.GroupIndex != -1 || package.Hidden) {
+ // Break on long option names.
+ if (Pad < 0) {
+ OS << "\n";
+ Pad = OptionFieldWidth + InitialPad;
+ }
+ OS.indent(Pad + 1) << "[";
+ if (package.GroupIndex != -1) {
+ OS << "Group=" << StaticGroupInfo[package.GroupIndex].FullName;
+ if (package.Hidden)
+ OS << ", ";
+ }
+ if (package.Hidden)
+ OS << "Hidden";
+ OS << "]";
+ }
+
+ OS << "\n";
+ }
+}
+
typedef std::map<std::string, const StaticCheckerInfoRec *> SortedCheckers;
static void printCheckerOption(llvm::raw_ostream &OS,SortedCheckers &checkers) {
@@ -161,6 +240,7 @@
for (SortedCheckers::iterator
I = checkers.begin(), E = checkers.end(); I != E; ++I) {
const std::string &Option = I->first;
+ const StaticCheckerInfoRec &checker = *I->second;
int Pad = OptionFieldWidth - int(Option.size());
OS.indent(InitialPad) << Option;
@@ -169,11 +249,36 @@
OS << "\n";
Pad = OptionFieldWidth + InitialPad;
}
- OS.indent(Pad + 1) << I->second->HelpText << '\n';
+ OS.indent(Pad + 1) << checker.HelpText;
+
+ if (checker.GroupIndex != -1 || checker.Hidden) {
+ OS << " [";
+ if (checker.GroupIndex != -1) {
+ OS << "Group=" << StaticGroupInfo[checker.GroupIndex].FullName;
+ if (checker.Hidden)
+ OS << ", ";
+ }
+ if (checker.Hidden)
+ OS << "Hidden";
+ OS << "]";
+ }
+
+ OS << "\n";
}
}
void ClangSACheckerProvider::printHelp(llvm::raw_ostream &OS) {
+ OS << "USAGE: -analyzer-checker <CHECKER or PACKAGE or GROUP,...>\n";
+
+ OS << "\nGROUPS:\n";
+ for (unsigned i = 0; i != NumGroups; ++i)
+ OS.indent(2) << StaticGroupInfo[i].FullName << "\n";
+
+ OS << "\nPACKAGES:\n";
+ printPackageOption(OS);
+
+ OS << "\nCHECKERS:\n";
+
// Sort checkers according to their full name.
SortedCheckers checkers;
for (unsigned i = 0; i != NumCheckers; ++i)
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h?rev=128511&r1=128510&r2=128511&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ClangSACheckers.h Tue Mar 29 18:57:38 2011
@@ -21,7 +21,7 @@
class CheckerManager;
#define GET_CHECKERS
-#define CHECKER(FULLNAME,CLASS,CXXFILE,HELPTEXT,HIDDEN) \
+#define CHECKER(FULLNAME,CLASS,CXXFILE,HELPTEXT,GROUPINDEX,HIDDEN) \
void register##CLASS(CheckerManager &mgr);
#include "Checkers.inc"
#undef CHECKER
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp?rev=128511&r1=128510&r2=128511&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp Tue Mar 29 18:57:38 2011
@@ -57,9 +57,6 @@
void ento::printCheckerHelp(llvm::raw_ostream &OS) {
OS << "OVERVIEW: Clang Static Analyzer Checkers List\n";
OS << '\n';
- OS << "USAGE: -analyzer-checker <check1,check2,...>\n";
- OS << '\n';
- OS << "CHECKERS:\n";
llvm::OwningPtr<CheckerProvider> provider(createClangSACheckerProvider());
provider->printHelp(OS);
More information about the cfe-commits
mailing list