clang: lib/AST/StmtViz.cpp Source File (original) (raw)
Go to the documentation of this file.
1
2
3
4
5
6
7
8
9
10
11
12
13
16#include "llvm/Support/GraphWriter.h"
17
18using namespace clang;
19
21#ifndef NDEBUG
22 llvm::ViewGraph(this,"AST");
23#else
24 llvm::errs() << "Stmt::viewAST is only available in debug builds on "
25 << "systems with Graphviz or gv!\n";
26#endif
27}
28
29namespace llvm {
30template<>
33
35
36#ifndef NDEBUG
37 std::string OutStr;
38 llvm::raw_string_ostream Out(OutStr);
39
41 Out << Node->getStmtClassName();
42 else
43 Out << "";
44
45 if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
46
47
48 for (unsigned i = 0; i != OutStr.length(); ++i)
49 if (OutStr[i] == '\n') {
50 OutStr[i] = '\\';
51 OutStr.insert(OutStr.begin()+i+1, 'l');
52 }
53
54 return OutStr;
55#else
56 return "";
57#endif
58 }
59};
60}
Stmt - This represents one statement.
void viewAST() const
viewAST - Visualize an AST rooted at this Stmt* using GraphViz.
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
DOTGraphTraits(bool isSimple=false)
static std::string getNodeLabel(const Stmt *Node, const Stmt *Graph)