]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/clang/Frontend/ASTConsumers.h
Update clang to r90226.
[FreeBSD/FreeBSD.git] / include / clang / Frontend / ASTConsumers.h
1 //===--- ASTConsumers.h - ASTConsumer implementations -----------*- 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 // AST Consumers.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef DRIVER_ASTCONSUMERS_H
15 #define DRIVER_ASTCONSUMERS_H
16
17 #include <string>
18
19 namespace llvm {
20   class raw_ostream;
21   class Module;
22   class LLVMContext;
23   namespace sys { class Path; }
24 }
25 namespace clang {
26
27 class ASTConsumer;
28 class CodeGenOptions;
29 class Diagnostic;
30 class FileManager;
31 class LangOptions;
32 class Preprocessor;
33 class TargetOptions;
34
35 // AST pretty-printer: prints out the AST in a format that is close to the
36 // original C code.  The output is intended to be in a format such that
37 // clang could re-parse the output back into the same AST, but the
38 // implementation is still incomplete.
39 ASTConsumer *CreateASTPrinter(llvm::raw_ostream *OS);
40
41 // AST XML-printer: prints out the AST in a XML format
42 // The output is intended to be in a format such that
43 // clang or any other tool could re-parse the output back into the same AST,
44 // but the implementation is still incomplete.
45 ASTConsumer *CreateASTPrinterXML(llvm::raw_ostream *OS);
46
47 // AST dumper: dumps the raw AST in human-readable form to stderr; this is
48 // intended for debugging.
49 ASTConsumer *CreateASTDumper();
50
51 // Graphical AST viewer: for each function definition, creates a graph of
52 // the AST and displays it with the graph viewer "dotty".  Also outputs
53 // function declarations to stderr.
54 ASTConsumer *CreateASTViewer();
55
56 // DeclContext printer: prints out the DeclContext tree in human-readable form
57 // to stderr; this is intended for debugging.
58 ASTConsumer *CreateDeclContextPrinter();
59
60 // RecordLayout dumper: prints out the record layout information for all records
61 // in the translation unit; this is intended for debugging.
62 ASTConsumer *CreateRecordLayoutDumper();
63
64 // ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code.
65 // This is considered experimental, and only works with Apple's ObjC runtime.
66 ASTConsumer *CreateObjCRewriter(const std::string &InFile,
67                                 llvm::raw_ostream *OS,
68                                 Diagnostic &Diags,
69                                 const LangOptions &LOpts,
70                                 bool SilenceRewriteMacroWarning);
71
72 // LLVM code generator: uses the code generation backend to generate LLVM
73 // assembly. This runs optimizations depending on the CodeGenOptions
74 // parameter. The output depends on the Action parameter.
75 enum BackendAction {
76   Backend_EmitAssembly,  // Emit native assembly
77   Backend_EmitBC,        // Emit LLVM bitcode file
78   Backend_EmitLL,        // Emit human-readable LLVM assembly
79   Backend_EmitNothing    // Don't emit anything (benchmarking mode)
80 };
81 ASTConsumer *CreateBackendConsumer(BackendAction Action,
82                                    Diagnostic &Diags,
83                                    const LangOptions &Features,
84                                    const CodeGenOptions &CodeGenOpts,
85                                    const TargetOptions &TargetOpts,
86                                    bool TimePasses,
87                                    const std::string &ModuleID,
88                                    llvm::raw_ostream *OS,
89                                    llvm::LLVMContext& C);
90
91 /// CreateHTMLPrinter - Create an AST consumer which rewrites source code to
92 /// HTML with syntax highlighting suitable for viewing in a web-browser.
93 ASTConsumer *CreateHTMLPrinter(llvm::raw_ostream *OS, Preprocessor &PP,
94                                bool SyntaxHighlight = true,
95                                bool HighlightMacros = true);
96
97 // PCH generator: generates a precompiled header file; this file can be
98 // used later with the PCHReader (clang-cc option -include-pch)
99 // to speed up compile times.
100 ASTConsumer *CreatePCHGenerator(const Preprocessor &PP,
101                                 llvm::raw_ostream *OS,
102                                 const char *isysroot = 0);
103
104 // Block rewriter: rewrites code using the Apple blocks extension to pure
105 // C code.  Output is always sent to stdout.
106 ASTConsumer *CreateBlockRewriter(const std::string &InFile,
107                                  Diagnostic &Diags,
108                                  const LangOptions &LangOpts);
109
110 // Inheritance viewer: for C++ code, creates a graph of the inheritance
111 // tree for the given class and displays it with "dotty".
112 ASTConsumer *CreateInheritanceViewer(const std::string& clsname);
113
114 } // end clang namespace
115
116 #endif