[PATCH] D46187: [Analyzer] getRegisteredCheckers(): handle debug checkers too.
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 27 06:47:39 PDT 2018
lebedev.ri created this revision.
lebedev.ri added reviewers: dcoughlin, alexfh, aaron.ballman, george.karpenkov, NoQ.
Herald added subscribers: a.sidorin, szepet, xazax.hun.
I would like to be able to trigger these debug checkers from clang-tidy, as a follow-up patch for https://reviews.llvm.org/D46159
Repository:
rC Clang
https://reviews.llvm.org/D46187
Files:
include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
Index: unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
===================================================================
--- unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
+++ unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
@@ -21,12 +21,18 @@
auto IsAlphaChecker = [](StringRef CheckerName) {
return CheckerName.startswith("alpha");
};
- const auto &AllCheckers =
- AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/true);
- EXPECT_FALSE(llvm::any_of(AllCheckers, IsDebugChecker));
+ const auto &AllCheckers = AnalyzerOptions::getRegisteredCheckers(
+ /*IncludeExperimental=*/true, /*IncludeDebug=*/true);
+ EXPECT_TRUE(llvm::any_of(AllCheckers, IsDebugChecker));
EXPECT_TRUE(llvm::any_of(AllCheckers, IsAlphaChecker));
- const auto &StableCheckers = AnalyzerOptions::getRegisteredCheckers();
+ const auto &AllNonDebugCheckers = AnalyzerOptions::getRegisteredCheckers(
+ /*IncludeExperimental=*/true, /*IncludeDebug=*/false);
+ EXPECT_FALSE(llvm::any_of(AllNonDebugCheckers, IsDebugChecker));
+ EXPECT_TRUE(llvm::any_of(AllNonDebugCheckers, IsAlphaChecker));
+
+ const auto &StableCheckers = AnalyzerOptions::getRegisteredCheckers(
+ /*IncludeExperimental=false,IncludeDebug=false*/);
EXPECT_FALSE(llvm::any_of(StableCheckers, IsDebugChecker));
EXPECT_FALSE(llvm::any_of(StableCheckers, IsAlphaChecker));
}
Index: lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===================================================================
--- lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -31,7 +31,8 @@
using namespace llvm;
std::vector<StringRef>
-AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental /* = false */) {
+AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental /* = false */,
+ bool IncludeDebug /* = false */) {
static const StringRef StaticAnalyzerChecks[] = {
#define GET_CHECKERS
#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN) \
@@ -42,9 +43,10 @@
};
std::vector<StringRef> Result;
for (StringRef CheckName : StaticAnalyzerChecks) {
- if (!CheckName.startswith("debug.") &&
- (IncludeExperimental || !CheckName.startswith("alpha.")))
- Result.push_back(CheckName);
+ if ((CheckName.startswith("alpha.") && !IncludeExperimental) ||
+ (CheckName.startswith("debug.") && !IncludeDebug))
+ continue;
+ Result.push_back(CheckName);
}
return Result;
}
Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===================================================================
--- include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -126,7 +126,8 @@
using ConfigTable = llvm::StringMap<std::string>;
static std::vector<StringRef>
- getRegisteredCheckers(bool IncludeExperimental = false);
+ getRegisteredCheckers(bool IncludeExperimental = false,
+ bool IncludeDebug = false);
/// \brief Pair of checker name and enable/disable.
std::vector<std::pair<std::string, bool>> CheckersControlList;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46187.144333.patch
Type: text/x-patch
Size: 3163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180427/2e10a880/attachment.bin>
More information about the cfe-commits
mailing list