summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
diff options
context:
space:
mode:
authorKristof Umann <dkszelethus@gmail.com>2019-03-04 00:28:16 +0000
committerKristof Umann <dkszelethus@gmail.com>2019-03-04 00:28:16 +0000
commit088b1c9cdcdb3d83fa730c1fcbae6db8252fe76d (patch)
tree3ff1101103765384e7f37bb997ee6cd88faf4fe1 /clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
parent195a62e9ae50594e469398631a24f4bc26061c56 (diff)
downloadbcm5719-llvm-088b1c9cdcdb3d83fa730c1fcbae6db8252fe76d.tar.gz
bcm5719-llvm-088b1c9cdcdb3d83fa730c1fcbae6db8252fe76d.zip
[analyzer] Enable subcheckers to possess checker options
Under the term "subchecker", I mean checkers that do not have a checker class on their own, like unix.MallocChecker to unix.DynamicMemoryModeling. Since a checker object was required in order to retrieve checker options, subcheckers couldn't possess options on their own. This patch is also an excuse to change the argument order of getChecker*Option, it always bothered me, now it resembles the actual command line argument (checkername:option=value). Differential Revision: https://reviews.llvm.org/D57579 llvm-svn: 355297
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
index d4d4459b37b..df5b46ebd2e 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -32,17 +32,14 @@ namespace {
class PaddingChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
private:
mutable std::unique_ptr<BugType> PaddingBug;
- mutable int64_t AllowedPad;
mutable BugReporter *BR;
public:
+ int64_t AllowedPad;
+
void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR,
BugReporter &BRArg) const {
BR = &BRArg;
- AllowedPad =
- MGR.getAnalyzerOptions()
- .getCheckerIntegerOption("AllowedPad", 24, this);
- assert(AllowedPad >= 0 && "AllowedPad option should be non-negative");
// The calls to checkAST* from AnalysisConsumer don't
// visit template instantiations or lambda classes. We
@@ -348,7 +345,11 @@ public:
} // namespace
void ento::registerPaddingChecker(CheckerManager &Mgr) {
- Mgr.registerChecker<PaddingChecker>();
+ auto *Checker = Mgr.registerChecker<PaddingChecker>();
+ Checker->AllowedPad = Mgr.getAnalyzerOptions()
+ .getCheckerIntegerOption(Checker, "AllowedPad", 24);
+ assert(Checker->AllowedPad >= 0 &&
+ "AllowedPad option should be non-negative");
}
bool ento::shouldRegisterPaddingChecker(const LangOptions &LO) {
OpenPOWER on IntegriCloud