Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -125,6 +125,9 @@ public: typedef llvm::StringMap ConfigTable; + static std::vector + getRegisteredCheckers(bool IncludeExperimental = false); + /// \brief Pair of checker name and enable/disable. std::vector > CheckersControlList; Index: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -23,6 +23,25 @@ using namespace ento; using namespace llvm; +std::vector +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 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 = Index: cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp =================================================================== --- cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp +++ cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp @@ -14,6 +14,23 @@ 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";