//===----------------------------------------------------------------------===//
/// 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);
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;
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
/// 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);
}