aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend/ASTConsumers.h
blob: 978b0d2b2aa61955ba58d75ba4d18846b33a27dd (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//===--- ASTConsumers.h - ASTConsumer implementations -----------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// AST Consumers.
//
//===----------------------------------------------------------------------===//

#ifndef DRIVER_ASTCONSUMERS_H
#define DRIVER_ASTCONSUMERS_H

#include <string>

namespace llvm {
  class raw_ostream;
  class Module;
  class LLVMContext;
  namespace sys { class Path; }
}
namespace clang {

class ASTConsumer;
class CodeGenOptions;
class Diagnostic;
class FileManager;
class LangOptions;
class Preprocessor;
class TargetOptions;

// AST pretty-printer: prints out the AST in a format that is close to the
// original C code.  The output is intended to be in a format such that
// clang could re-parse the output back into the same AST, but the
// implementation is still incomplete.
ASTConsumer *CreateASTPrinter(llvm::raw_ostream *OS);

// AST XML-printer: prints out the AST in a XML format
// The output is intended to be in a format such that
// clang or any other tool could re-parse the output back into the same AST,
// but the implementation is still incomplete.
ASTConsumer *CreateASTPrinterXML(llvm::raw_ostream *OS);

// AST dumper: dumps the raw AST in human-readable form to stderr; this is
// intended for debugging.
ASTConsumer *CreateASTDumper();

// Graphical AST viewer: for each function definition, creates a graph of
// the AST and displays it with the graph viewer "dotty".  Also outputs
// function declarations to stderr.
ASTConsumer *CreateASTViewer();

// DeclContext printer: prints out the DeclContext tree in human-readable form
// to stderr; this is intended for debugging.
ASTConsumer *CreateDeclContextPrinter();

// RecordLayout dumper: prints out the record layout information for all records
// in the translation unit; this is intended for debugging.
ASTConsumer *CreateRecordLayoutDumper();

// ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code.
// This is considered experimental, and only works with Apple's ObjC runtime.
ASTConsumer *CreateObjCRewriter(const std::string &InFile,
                                llvm::raw_ostream *OS,
                                Diagnostic &Diags,
                                const LangOptions &LOpts,
                                bool SilenceRewriteMacroWarning);

// LLVM code generator: uses the code generation backend to generate LLVM
// assembly. This runs optimizations depending on the CodeGenOptions
// parameter. The output depends on the Action parameter.
enum BackendAction {
  Backend_EmitAssembly,  // Emit native assembly
  Backend_EmitBC,        // Emit LLVM bitcode file
  Backend_EmitLL,        // Emit human-readable LLVM assembly
  Backend_EmitNothing    // Don't emit anything (benchmarking mode)
};
ASTConsumer *CreateBackendConsumer(BackendAction Action,
                                   Diagnostic &Diags,
                                   const LangOptions &Features,
                                   const CodeGenOptions &CodeGenOpts,
                                   const TargetOptions &TargetOpts,
                                   bool TimePasses,
                                   const std::string &ModuleID,
                                   llvm::raw_ostream *OS,
                                   llvm::LLVMContext& C);

/// CreateHTMLPrinter - Create an AST consumer which rewrites source code to
/// HTML with syntax highlighting suitable for viewing in a web-browser.
ASTConsumer *CreateHTMLPrinter(llvm::raw_ostream *OS, Preprocessor &PP,
                               bool SyntaxHighlight = true,
                               bool HighlightMacros = true);

// PCH generator: generates a precompiled header file; this file can be used
// later with the PCHReader (clang -cc1 option -include-pch) to speed up compile
// times.
ASTConsumer *CreatePCHGenerator(const Preprocessor &PP,
                                llvm::raw_ostream *OS,
                                const char *isysroot = 0);

// Inheritance viewer: for C++ code, creates a graph of the inheritance
// tree for the given class and displays it with "dotty".
ASTConsumer *CreateInheritanceViewer(const std::string& clsname);

} // end clang namespace

#endif