r229325 - Analyzer: Replace a set of particularly ugly faux variadics.
Benjamin Kramer
benny.kra at googlemail.com
Sun Feb 15 12:11:07 PST 2015
Author: d0k
Date: Sun Feb 15 14:11:07 2015
New Revision: 229325
URL: http://llvm.org/viewvc/llvm-project?rev=229325&view=rev
Log:
Analyzer: Replace a set of particularly ugly faux variadics.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
cfe/trunk/lib/StaticAnalyzer/Core/Checker.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h?rev=229325&r1=229324&r2=229325&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h Sun Feb 15 14:11:07 2015
@@ -25,10 +25,6 @@ namespace ento {
namespace check {
-struct _VoidCheck {
- static void _register(void *checker, CheckerManager &mgr) { }
-};
-
template <typename DECL>
class ASTDecl {
template <typename CHECKER>
@@ -476,49 +472,22 @@ public:
CheckerProgramPointTag(const CheckerBase *Checker, StringRef Msg);
};
-template <typename CHECK1, typename CHECK2=check::_VoidCheck,
- typename CHECK3=check::_VoidCheck, typename CHECK4=check::_VoidCheck,
- typename CHECK5=check::_VoidCheck, typename CHECK6=check::_VoidCheck,
- typename CHECK7=check::_VoidCheck, typename CHECK8=check::_VoidCheck,
- typename CHECK9=check::_VoidCheck, typename CHECK10=check::_VoidCheck,
- typename CHECK11=check::_VoidCheck,typename CHECK12=check::_VoidCheck,
- typename CHECK13=check::_VoidCheck,typename CHECK14=check::_VoidCheck,
- typename CHECK15=check::_VoidCheck,typename CHECK16=check::_VoidCheck,
- 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<check::_VoidCheck>
- : public CheckerBase
-{
- virtual void anchor();
-public:
- static void _register(void *checker, CheckerManager &mgr) { }
-};
-
-template <typename CHECK1, typename CHECK2, typename CHECK3, typename CHECK4,
- typename CHECK5, typename CHECK6, typename CHECK7, typename CHECK8,
- typename CHECK9, typename CHECK10,typename CHECK11,typename CHECK12,
- typename CHECK13,typename CHECK14,typename CHECK15,typename CHECK16,
- typename CHECK17,typename CHECK18,typename CHECK19,typename CHECK20,
- typename CHECK21,typename CHECK22,typename CHECK23,typename CHECK24>
-class Checker
- : public CHECK1,
- public Checker<CHECK2, CHECK3, CHECK4, CHECK5, CHECK6, CHECK7,
- CHECK8, CHECK9, CHECK10,CHECK11,CHECK12,CHECK13,
- CHECK14,CHECK15,CHECK16,CHECK17,CHECK18,CHECK19,
- CHECK20,CHECK21,CHECK22,CHECK23,CHECK24> {
+template <typename CHECK1, typename... CHECKs>
+class Checker : public CHECK1, public Checker<CHECKs...> {
+public:
+ template <typename CHECKER>
+ static void _register(CHECKER *checker, CheckerManager &mgr) {
+ CHECK1::_register(checker, mgr);
+ Checker<CHECKs...>::_register(checker, mgr);
+ }
+};
+
+template <typename CHECK1>
+class Checker<CHECK1> : public CHECK1, public CheckerBase {
public:
template <typename CHECKER>
static void _register(CHECKER *checker, CheckerManager &mgr) {
CHECK1::_register(checker, mgr);
- Checker<CHECK2, CHECK3, CHECK4, CHECK5, CHECK6, CHECK7,
- CHECK8, CHECK9, CHECK10,CHECK11,CHECK12,CHECK13,
- CHECK14,CHECK15,CHECK16,CHECK17,CHECK18,CHECK19,
- CHECK20,CHECK21,CHECK22,CHECK23,CHECK24>::_register(checker, mgr);
}
};
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=229325&r1=229324&r2=229325&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Sun Feb 15 14:11:07 2015
@@ -47,71 +47,18 @@ namespace ento {
template <typename T> class CheckerFn;
-template <typename RET, typename P1, typename P2, typename P3, typename P4,
- typename P5>
-class CheckerFn<RET(P1, P2, P3, P4, P5)> {
- typedef RET (*Func)(void *, P1, P2, P3, P4, P5);
+template <typename RET, typename... Ps>
+class CheckerFn<RET(Ps...)> {
+ typedef RET (*Func)(void *, Ps...);
Func Fn;
public:
CheckerBase *Checker;
CheckerFn(CheckerBase *checker, Func fn) : Fn(fn), Checker(checker) { }
- RET operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const {
- return Fn(Checker, p1, p2, p3, p4, p5);
+ RET operator()(Ps... ps) const {
+ return Fn(Checker, ps...);
}
};
-template <typename RET, typename P1, typename P2, typename P3, typename P4>
-class CheckerFn<RET(P1, P2, P3, P4)> {
- typedef RET (*Func)(void *, P1, P2, P3, P4);
- Func Fn;
-public:
- CheckerBase *Checker;
- CheckerFn(CheckerBase *checker, Func fn) : Fn(fn), Checker(checker) { }
- RET operator()(P1 p1, P2 p2, P3 p3, P4 p4) const {
- return Fn(Checker, p1, p2, p3, p4);
- }
-};
-
-template <typename RET, typename P1, typename P2, typename P3>
-class CheckerFn<RET(P1, P2, P3)> {
- typedef RET (*Func)(void *, P1, P2, P3);
- Func Fn;
-public:
- CheckerBase *Checker;
- CheckerFn(CheckerBase *checker, Func fn) : Fn(fn), Checker(checker) { }
- RET operator()(P1 p1, P2 p2, P3 p3) const { return Fn(Checker, p1, p2, p3); }
-};
-
-template <typename RET, typename P1, typename P2>
-class CheckerFn<RET(P1, P2)> {
- typedef RET (*Func)(void *, P1, P2);
- Func Fn;
-public:
- CheckerBase *Checker;
- CheckerFn(CheckerBase *checker, Func fn) : Fn(fn), Checker(checker) { }
- RET operator()(P1 p1, P2 p2) const { return Fn(Checker, p1, p2); }
-};
-
-template <typename RET, typename P1>
-class CheckerFn<RET(P1)> {
- typedef RET (*Func)(void *, P1);
- Func Fn;
-public:
- CheckerBase *Checker;
- CheckerFn(CheckerBase *checker, Func fn) : Fn(fn), Checker(checker) { }
- RET operator()(P1 p1) const { return Fn(Checker, p1); }
-};
-
-template <typename RET>
-class CheckerFn<RET()> {
- typedef RET (*Func)(void *);
- Func Fn;
-public:
- CheckerBase *Checker;
- CheckerFn(CheckerBase *checker, Func fn) : Fn(fn), Checker(checker) { }
- RET operator()() const { return Fn(Checker); }
-};
-
/// \brief Describes the different reasons a pointer escapes
/// during analysis.
enum PointerEscapeKind {
Modified: cfe/trunk/lib/StaticAnalyzer/Core/Checker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Checker.cpp?rev=229325&r1=229324&r2=229325&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/Checker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Checker.cpp Sun Feb 15 14:11:07 2015
@@ -36,11 +36,3 @@ raw_ostream& clang::ento::operator<<(raw
Out << Checker.getCheckName().getName();
return Out;
}
-
-void Checker<check::_VoidCheck, check::_VoidCheck, check::_VoidCheck,
- check::_VoidCheck, check::_VoidCheck, check::_VoidCheck,
- check::_VoidCheck, check::_VoidCheck, check::_VoidCheck,
- check::_VoidCheck, check::_VoidCheck, check::_VoidCheck,
- check::_VoidCheck, check::_VoidCheck, check::_VoidCheck,
- check::_VoidCheck, check::_VoidCheck, check::_VoidCheck
- >::anchor() { }
More information about the cfe-commits
mailing list