Implicitly expand argument packs when performing template argument
[clang.git] / include / clang / Checker / PathSensitive / CheckerVisitor.h
blob241d9e39ad2cc794696a20230e5aa704cdcecc58
1 //== CheckerVisitor.h - Abstract visitor for checkers ------------*- C++ -*--=//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines CheckerVisitor.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_ANALYSIS_CHECKERVISITOR
15 #define LLVM_CLANG_ANALYSIS_CHECKERVISITOR
16 #include "clang/Checker/PathSensitive/Checker.h"
18 namespace clang {
20 //===----------------------------------------------------------------------===//
21 // Checker visitor interface. Used by subclasses of Checker to specify their
22 // own checker visitor logic.
23 //===----------------------------------------------------------------------===//
25 /// CheckerVisitor - This class implements a simple visitor for Stmt subclasses.
26 /// Since Expr derives from Stmt, this also includes support for visiting Exprs.
27 template<typename ImplClass>
28 class CheckerVisitor : public Checker {
29 public:
30 virtual void _PreVisit(CheckerContext &C, const Stmt *S) {
31 PreVisit(C, S);
34 virtual void _PostVisit(CheckerContext &C, const Stmt *S) {
35 PostVisit(C, S);
38 void PreVisit(CheckerContext &C, const Stmt *S) {
39 switch (S->getStmtClass()) {
40 default:
41 assert(false && "Unsupport statement.");
42 return;
43 case Stmt::CompoundAssignOperatorClass:
44 static_cast<ImplClass*>(this)->PreVisitBinaryOperator(C,
45 static_cast<const BinaryOperator*>(S));
46 break;
48 #define PREVISIT(NAME, FALLBACK) \
49 case Stmt::NAME ## Class:\
50 static_cast<ImplClass*>(this)->PreVisit ## NAME(C,static_cast<const NAME*>(S));\
51 break;
52 #include "clang/Checker/PathSensitive/CheckerVisitor.def"
56 void PostVisit(CheckerContext &C, const Stmt *S) {
57 switch (S->getStmtClass()) {
58 default:
59 assert(false && "Unsupport statement.");
60 return;
61 case Stmt::CompoundAssignOperatorClass:
62 static_cast<ImplClass*>(this)->PostVisitBinaryOperator(C,
63 static_cast<const BinaryOperator*>(S));
64 break;
66 #define POSTVISIT(NAME, FALLBACK) \
67 case Stmt::NAME ## Class:\
68 static_cast<ImplClass*>(this)->\
69 PostVisit ## NAME(C,static_cast<const NAME*>(S));\
70 break;
71 #include "clang/Checker/PathSensitive/CheckerVisitor.def"
75 void PreVisitGenericCall(CheckerContext &C, const CallExpr *CE) {
76 static_cast<ImplClass*>(this)->PreVisitStmt(C, CE);
78 void PostVisitGenericCall(CheckerContext &C, const CallExpr *CE) {
79 static_cast<ImplClass*>(this)->PostVisitStmt(C, CE);
82 void PreVisitStmt(CheckerContext &C, const Stmt *S) {
83 *C.respondsToCallback = false;
86 void PostVisitStmt(CheckerContext &C, const Stmt *S) {
87 *C.respondsToCallback = false;
90 void PreVisitCastExpr(CheckerContext &C, const CastExpr *E) {
91 static_cast<ImplClass*>(this)->PreVisitStmt(C, E);
94 #define PREVISIT(NAME, FALLBACK) \
95 void PreVisit ## NAME(CheckerContext &C, const NAME* S) {\
96 static_cast<ImplClass*>(this)->PreVisit ## FALLBACK(C, S);\
98 #define POSTVISIT(NAME, FALLBACK) \
99 void PostVisit ## NAME(CheckerContext &C, const NAME* S) {\
100 static_cast<ImplClass*>(this)->PostVisit ## FALLBACK(C, S);\
102 #include "clang/Checker/PathSensitive/CheckerVisitor.def"
105 } // end clang namespace
107 #endif