Summary:
This provides a better interface for clang-tidy and encapsulates the knowledge
about experimental checkers instead of leaving this to the clients.
Reviewers: zaks.anna
Subscribers: a.sidorin, NoQ, dcoughlin, cfe-commits
Differential Revision: https://reviews.llvm.org/D26310
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286218
91177308-0d34-0410-b5e6-
96231b3b80d8
public:
typedef llvm::StringMap<std::string> ConfigTable;
+ static std::vector<StringRef>
+ getRegisteredCheckers(bool IncludeExperimental = false);
+
/// \brief Pair of checker name and enable/disable.
std::vector<std::pair<std::string, bool> > CheckersControlList;
using namespace ento;
using namespace llvm;
+std::vector<StringRef>
+AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental /* = false */) {
+ static const StringRef StaticAnalyzerChecks[] = {
+#define GET_CHECKERS
+#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN) \
+ FULLNAME,
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER
+#undef GET_CHECKERS
+ };
+ std::vector<StringRef> Result;
+ for (StringRef CheckName : StaticAnalyzerChecks) {
+ if (!CheckName.startswith("debug.") &&
+ (IncludeExperimental || !CheckName.startswith("alpha.")))
+ Result.push_back(CheckName);
+ }
+ return Result;
+}
+
AnalyzerOptions::UserModeKind AnalyzerOptions::getUserMode() {
if (UserMode == UMK_NotSet) {
StringRef ModeStr =
namespace clang {
namespace ento {
+TEST(StaticAnalyzerOptions, getRegisteredCheckers) {
+ auto IsDebugChecker = [](StringRef CheckerName) {
+ return CheckerName.startswith("debug");
+ };
+ auto IsAlphaChecker = [](StringRef CheckerName) {
+ return CheckerName.startswith("alpha");
+ };
+ const auto &AllCheckers =
+ AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/true);
+ EXPECT_FALSE(llvm::any_of(AllCheckers, IsDebugChecker));
+ EXPECT_TRUE(llvm::any_of(AllCheckers, IsAlphaChecker));
+
+ const auto &StableCheckers = AnalyzerOptions::getRegisteredCheckers();
+ EXPECT_FALSE(llvm::any_of(StableCheckers, IsDebugChecker));
+ EXPECT_FALSE(llvm::any_of(StableCheckers, IsAlphaChecker));
+}
+
TEST(StaticAnalyzerOptions, SearchInParentPackageTests) {
AnalyzerOptions Opts;
Opts.Config["Outer.Inner.CheckerOne:Option"] = "true";