[PATCH] D49050: [analyzer] Pass through all arguments from the registerChecker() to the checker constructor
George Karpenkov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 10 18:28:32 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC336753: [analyzer] Pass through all arguments from the registerChecker() to the checker… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.
Repository:
rC Clang
https://reviews.llvm.org/D49050
Files:
include/clang/StaticAnalyzer/Core/CheckerManager.h
lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -56,6 +56,12 @@
check::PostStmt<CXXNewExpr>,
check::PreObjCMessage,
check::PostObjCMessage > {
+private:
+ /// This value is set to true, when the Generics checker is turned on.
+ bool CheckGenerics;
+public:
+ DynamicTypePropagation(bool CheckGenerics)
+ : CheckGenerics(CheckGenerics) {}
const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr *MsgE,
CheckerContext &C) const;
@@ -107,9 +113,6 @@
void checkDeadSymbols(SymbolReaper &SR, CheckerContext &C) const;
void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
-
- /// This value is set to true, when the Generics checker is turned on.
- DefaultBool CheckGenerics;
};
} // end anonymous namespace
@@ -995,11 +998,9 @@
/// Register checkers.
void ento::registerObjCGenericsChecker(CheckerManager &mgr) {
- DynamicTypePropagation *checker =
- mgr.registerChecker<DynamicTypePropagation>();
- checker->CheckGenerics = true;
+ mgr.registerChecker<DynamicTypePropagation>(/*CheckGenerics=*/true);
}
void ento::registerDynamicTypePropagation(CheckerManager &mgr) {
- mgr.registerChecker<DynamicTypePropagation>();
+ mgr.registerChecker<DynamicTypePropagation>(/*CheckGenerics=*/false);
}
Index: include/clang/StaticAnalyzer/Core/CheckerManager.h
===================================================================
--- include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -144,31 +144,18 @@
//===----------------------------------------------------------------------===//
/// Used to register checkers.
+ /// All arguments are automatically passed through to the checker
+ /// constructor.
///
/// \returns a pointer to the checker object.
- template <typename CHECKER>
- CHECKER *registerChecker() {
- CheckerTag tag = getTag<CHECKER>();
- CheckerRef &ref = CheckerTags[tag];
- if (ref)
- return static_cast<CHECKER *>(ref); // already registered.
-
- CHECKER *checker = new CHECKER();
- checker->Name = CurrentCheckName;
- CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
- CHECKER::_register(checker, *this);
- ref = checker;
- return checker;
- }
-
- template <typename CHECKER>
- CHECKER *registerChecker(AnalyzerOptions &AOpts) {
+ template <typename CHECKER, typename... AT>
+ CHECKER *registerChecker(AT... Args) {
CheckerTag tag = getTag<CHECKER>();
CheckerRef &ref = CheckerTags[tag];
if (ref)
return static_cast<CHECKER *>(ref); // already registered.
- CHECKER *checker = new CHECKER(AOpts);
+ CHECKER *checker = new CHECKER(Args...);
checker->Name = CurrentCheckName;
CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
CHECKER::_register(checker, *this);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49050.154915.patch
Type: text/x-patch
Size: 3232 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180711/390cbf76/attachment.bin>
More information about the cfe-commits
mailing list