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