From 96479da6ad9d921d875e7be29fe1bfa127be8069 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Mon, 2 Jul 2012 19:28:16 +0000 Subject: [analyzer] Add generic preCall and postCall checks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159562 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/StaticAnalyzer/Core/Checker.h | 59 ++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 14 deletions(-) (limited to 'include/clang/StaticAnalyzer/Core/Checker.h') diff --git a/include/clang/StaticAnalyzer/Core/Checker.h b/include/clang/StaticAnalyzer/Core/Checker.h index 07a1ccff6c..3214d96c53 100644 --- a/include/clang/StaticAnalyzer/Core/Checker.h +++ b/include/clang/StaticAnalyzer/Core/Checker.h @@ -150,6 +150,36 @@ public: } }; +class PreCall { + template + static void _checkCall(void *checker, const CallEvent &msg, + CheckerContext &C) { + ((const CHECKER *)checker)->checkPreCall(msg, C); + } + +public: + template + static void _register(CHECKER *checker, CheckerManager &mgr) { + mgr._registerForPreCall( + CheckerManager::CheckCallFunc(checker, _checkCall)); + } +}; + +class PostCall { + template + static void _checkCall(void *checker, const CallEvent &msg, + CheckerContext &C) { + ((const CHECKER *)checker)->checkPostCall(msg, C); + } + +public: + template + static void _register(CHECKER *checker, CheckerManager &mgr) { + mgr._registerForPostCall( + CheckerManager::CheckCallFunc(checker, _checkCall)); + } +}; + class Location { template static void _checkLocation(void *checker, @@ -372,16 +402,14 @@ template + typename CHECK17=check::_VoidCheck,typename CHECK18=check::_VoidCheck, + typename CHECK19=check::_VoidCheck,typename CHECK20=check::_VoidCheck, + typename CHECK21=check::_VoidCheck,typename CHECK22=check::_VoidCheck, + typename CHECK23=check::_VoidCheck,typename CHECK24=check::_VoidCheck> class Checker; template <> -class Checker +class Checker : public CheckerBase { virtual void anchor(); @@ -393,19 +421,22 @@ template + typename CHECK17,typename CHECK18,typename CHECK19,typename CHECK20, + typename CHECK21,typename CHECK22,typename CHECK23,typename CHECK24> class Checker : public CHECK1, - public Checker { + public Checker { public: template static void _register(CHECKER *checker, CheckerManager &mgr) { CHECK1::_register(checker, mgr); - Checker::_register(checker, mgr); + Checker::_register(checker, mgr); } }; -- cgit v1.2.3-18-g5258