ASTConsumers.h revision 1eb4433ac451dc16f4133a88af2d002ac26c58ef
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 19namespace llvm { 20 class raw_ostream; 21 class Module; 22 class LLVMContext; 23 namespace sys { class Path; } 24} 25namespace clang { 26 27class ASTConsumer; 28class Diagnostic; 29class FileManager; 30class Preprocessor; 31class PreprocessorFactory; 32class CompileOptions; 33class LangOptions; 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. 39ASTConsumer *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. 45ASTConsumer *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. 49ASTConsumer *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. 54ASTConsumer *CreateASTViewer(); 55 56// DeclContext printer: prints out the DeclContext tree in human-readable form 57// to stderr; this is intended for debugging. 58ASTConsumer *CreateDeclContextPrinter(); 59 60// ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code. 61// This is considered experimental, and only works with Apple's ObjC runtime. 62ASTConsumer *CreateObjCRewriter(const std::string &InFile, 63 llvm::raw_ostream *OS, 64 Diagnostic &Diags, 65 const LangOptions &LOpts, 66 bool SilenceRewriteMacroWarning); 67 68// LLVM code generator: uses the code generation backend to generate LLVM 69// assembly. This runs optimizations depending on the CompileOptions 70// parameter. The output depends on the Action parameter. 71enum BackendAction { 72 Backend_EmitAssembly, // Emit native assembly 73 Backend_EmitBC, // Emit LLVM bitcode file 74 Backend_EmitLL, // Emit human-readable LLVM assembly 75 Backend_EmitNothing // Don't emit anything (benchmarking mode) 76}; 77ASTConsumer *CreateBackendConsumer(BackendAction Action, 78 Diagnostic &Diags, 79 const LangOptions &Features, 80 const CompileOptions &CompileOpts, 81 const std::string &ModuleID, 82 llvm::raw_ostream *OS, 83 llvm::LLVMContext& C); 84 85// HTML printer: uses the rewriter to convert source code to HTML with 86// syntax highlighting suitable for viewing in a web-browser. 87ASTConsumer* CreateHTMLPrinter(llvm::raw_ostream *OS, Diagnostic &D, 88 Preprocessor *PP, PreprocessorFactory *PPF); 89 90// PCH generator: generates a precompiled header file; this file can be 91// used later with the PCHReader (clang-cc option -include-pch) 92// to speed up compile times. 93ASTConsumer *CreatePCHGenerator(const Preprocessor &PP, 94 llvm::raw_ostream *OS, 95 const char *isysroot = 0); 96 97// Block rewriter: rewrites code using the Apple blocks extension to pure 98// C code. Output is always sent to stdout. 99ASTConsumer *CreateBlockRewriter(const std::string &InFile, 100 Diagnostic &Diags, 101 const LangOptions &LangOpts); 102 103// Inheritance viewer: for C++ code, creates a graph of the inheritance 104// tree for the given class and displays it with "dotty". 105ASTConsumer *CreateInheritanceViewer(const std::string& clsname); 106 107} // end clang namespace 108 109#endif 110