-
Notifications
You must be signed in to change notification settings - Fork 0
/
rav-printer-visitor-private.h
66 lines (50 loc) · 2.19 KB
/
rav-printer-visitor-private.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// rav-printer-visitor-private.h
// Private decls for rav-printer-visitor.
#ifndef RAV_PRINTER_VISITOR_PRIVATE_H
#define RAV_PRINTER_VISITOR_PRIVATE_H
#include "rav-printer-visitor.h" // public decls for this module
// this dir
#include "clang-util.h" // ClangUtil
// clang
#include "clang/AST/RecursiveASTVisitor.h" // clang::RecursiveASTVisitor
// libc++
#include <iosfwd> // std::ostream
#include <string> // std::string
// Use RAV to print AST nodes.
class RAVPrinterVisitor : public ClangUtil,
public clang::RecursiveASTVisitor<RAVPrinterVisitor> {
public: // types
// Name of the base class visitor, to make it easier to call its
// methods from the same-named methods when overridden.
typedef clang::RecursiveASTVisitor<RAVPrinterVisitor> BaseClass;
public: // data
// Number of levels of indentation to print.
int m_indentLevel;
// Stream to print to.
std::ostream &m_os;
public: // methods
RAVPrinterVisitor(std::ostream &os, clang::ASTContext &astContext)
: ClangUtil(astContext),
clang::RecursiveASTVisitor<RAVPrinterVisitor>(),
m_indentLevel(0),
m_os(os)
{}
// This is an exact copy of the private base class method, defined again
// so I can call in order to fix other misbehavior in RAV.
bool TraverseTemplateParameterListHelper(clang::TemplateParameterList *TPL);
// Indentation string corresponding to 'm_indentLevel'.
std::string indentString() const;
// RecursiveASTVisitor customization.
bool shouldVisitTemplateInstantiations() const { return true; }
bool shouldVisitImplicitCode() const { return true; }
// RecursiveASTVisitor methods.
bool TraverseDecl(clang::Decl *decl);
bool dataTraverseStmtPre(clang::Stmt *stmt);
bool dataTraverseStmtPost(clang::Stmt *stmt);
bool TraverseType(clang::QualType T);
bool TraverseTypeLoc(clang::TypeLoc TL);
bool TraverseTemplateArgumentLoc(clang::TemplateArgumentLoc tal);
bool TraverseQualifiedTypeLoc(clang::QualifiedTypeLoc TL);
bool TraverseNestedNameSpecifierLoc(clang::NestedNameSpecifierLoc nnsl);
};
#endif // RAV_PRINTER_VISITOR_PRIVATE_H