1 //==- CFGRecStmtVisitor - Recursive visitor of CFG statements ---*- C++ --*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the template class CFGRecStmtVisitor, which extends
11 // CFGStmtVisitor by implementing a default recursive visit of all statements.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_ANALYSIS_CFG_REC_STMT_VISITOR_H
16 #define LLVM_CLANG_ANALYSIS_CFG_REC_STMT_VISITOR_H
18 #include "clang/Analysis/Visitors/CFGStmtVisitor.h"
21 template <typename ImplClass>
22 class CFGRecStmtVisitor : public CFGStmtVisitor<ImplClass,void> {
25 void VisitStmt(Stmt *S) {
26 static_cast< ImplClass* >(this)->VisitChildren(S);
29 void VisitCompoundStmt(CompoundStmt *S) {
30 // Do nothing. Everything in a CompoundStmt is inlined
34 void VisitConditionVariableInit(Stmt *S) {
35 assert(S == this->getCurrentBlkStmt());
37 switch (S->getStmtClass()) {
38 #define CONDVAR_CASE(CLASS) \
39 case Stmt::CLASS ## Class:\
40 CondVar = cast<CLASS>(S)->getConditionVariable();\
44 CONDVAR_CASE(SwitchStmt)
45 CONDVAR_CASE(WhileStmt)
48 llvm_unreachable("Infeasible");
50 static_cast<ImplClass*>(this)->Visit(CondVar->getInit());
53 // Defining operator() allows the visitor to be used as a C++ style functor.
54 void operator()(Stmt *S) { static_cast<ImplClass*>(this)->BlockStmt_Visit(S);}
57 } // end namespace clang