blob: 978b0d2b2aa61955ba58d75ba4d18846b33a27dd [file] [log] [blame]
Chris Lattner97e8b6f2007-10-07 06:04:32 +00001//===--- ASTConsumers.h - ASTConsumer implementations -----------*- C++ -*-===//
Reid Spencer5f016e22007-07-11 17:01:13 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner97e8b6f2007-10-07 06:04:32 +000010// AST Consumers.
Reid Spencer5f016e22007-07-11 17:01:13 +000011//
12//===----------------------------------------------------------------------===//
13
Chris Lattner97e8b6f2007-10-07 06:04:32 +000014#ifndef DRIVER_ASTCONSUMERS_H
15#define DRIVER_ASTCONSUMERS_H
Reid Spencer5f016e22007-07-11 17:01:13 +000016
Eli Friedman7df3d712008-02-16 23:17:23 +000017#include <string>
Ted Kremenek1b5a4bd2007-11-27 21:46:50 +000018
Chris Lattnere66b65c2008-02-06 01:42:25 +000019namespace llvm {
Chris Lattner0fa0daa2009-08-24 04:11:30 +000020 class raw_ostream;
Chris Lattnere66b65c2008-02-06 01:42:25 +000021 class Module;
Benjamin Kramerf21efe92009-08-11 17:46:57 +000022 class LLVMContext;
Chris Lattnere66b65c2008-02-06 01:42:25 +000023 namespace sys { class Path; }
24}
Reid Spencer5f016e22007-07-11 17:01:13 +000025namespace clang {
26
Chris Lattner556beb72007-09-15 22:56:56 +000027class ASTConsumer;
Daniel Dunbard58c03f2009-11-15 06:48:46 +000028class CodeGenOptions;
Chris Lattnerc0508f92007-09-15 23:21:08 +000029class Diagnostic;
Ted Kremenekdca24662007-12-05 00:26:13 +000030class FileManager;
Cedric Venetea684e62009-02-14 16:15:20 +000031class LangOptions;
Daniel Dunbard58c03f2009-11-15 06:48:46 +000032class Preprocessor;
33class TargetOptions;
Ted Kremenek339b9c22008-04-17 22:31:54 +000034
Eli Friedman18d868f2009-05-18 01:16:21 +000035// 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.
Chris Lattner0fa0daa2009-08-24 04:11:30 +000039ASTConsumer *CreateASTPrinter(llvm::raw_ostream *OS);
Ted Kremenekfdfc1982007-12-19 22:24:34 +000040
Mike Stump1eb44332009-09-09 15:08:12 +000041// AST XML-printer: prints out the AST in a XML format
Douglas Gregoree75c052009-05-21 20:55:50 +000042// The output is intended to be in a format such that
Mike Stump1eb44332009-09-09 15:08:12 +000043// clang or any other tool could re-parse the output back into the same AST,
Douglas Gregoree75c052009-05-21 20:55:50 +000044// but the implementation is still incomplete.
Chris Lattner0fa0daa2009-08-24 04:11:30 +000045ASTConsumer *CreateASTPrinterXML(llvm::raw_ostream *OS);
Douglas Gregoree75c052009-05-21 20:55:50 +000046
Eli Friedman18d868f2009-05-18 01:16:21 +000047// AST dumper: dumps the raw AST in human-readable form to stderr; this is
Douglas Gregor4fe0c8e2009-05-30 00:08:05 +000048// intended for debugging.
49ASTConsumer *CreateASTDumper();
Ted Kremenekfdfc1982007-12-19 22:24:34 +000050
Eli Friedman18d868f2009-05-18 01:16:21 +000051// 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.
Ted Kremenek80de08f2007-09-19 21:29:43 +000054ASTConsumer *CreateASTViewer();
Ted Kremenekfdfc1982007-12-19 22:24:34 +000055
Eli Friedman18d868f2009-05-18 01:16:21 +000056// DeclContext printer: prints out the DeclContext tree in human-readable form
57// to stderr; this is intended for debugging.
Zhongxing Xu2d75d6f2009-01-13 01:29:24 +000058ASTConsumer *CreateDeclContextPrinter();
59
Anders Carlsson78762eb2009-09-24 18:54:49 +000060// RecordLayout dumper: prints out the record layout information for all records
61// in the translation unit; this is intended for debugging.
62ASTConsumer *CreateRecordLayoutDumper();
63
Eli Friedman18d868f2009-05-18 01:16:21 +000064// ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code.
65// This is considered experimental, and only works with Apple's ObjC runtime.
Chris Lattner0fa0daa2009-08-24 04:11:30 +000066ASTConsumer *CreateObjCRewriter(const std::string &InFile,
67 llvm::raw_ostream *OS,
Eli Friedmanbce831b2009-05-18 22:29:17 +000068 Diagnostic &Diags,
Eli Friedmanc6d656e2009-05-18 22:39:16 +000069 const LangOptions &LOpts,
70 bool SilenceRewriteMacroWarning);
Eli Friedman18d868f2009-05-18 01:16:21 +000071
72// LLVM code generator: uses the code generation backend to generate LLVM
Chandler Carruth2811ccf2009-11-12 17:24:48 +000073// assembly. This runs optimizations depending on the CodeGenOptions
Eli Friedman18d868f2009-05-18 01:16:21 +000074// parameter. The output depends on the Action parameter.
Daniel Dunbard69bacc2008-10-21 23:49:24 +000075enum BackendAction {
Eli Friedman18d868f2009-05-18 01:16:21 +000076 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)
Daniel Dunbard69bacc2008-10-21 23:49:24 +000080};
81ASTConsumer *CreateBackendConsumer(BackendAction Action,
82 Diagnostic &Diags,
83 const LangOptions &Features,
Chandler Carruth2811ccf2009-11-12 17:24:48 +000084 const CodeGenOptions &CodeGenOpts,
Daniel Dunbard58c03f2009-11-15 06:48:46 +000085 const TargetOptions &TargetOpts,
Daniel Dunbarb33fbaa2009-11-30 08:39:52 +000086 bool TimePasses,
Eli Friedman66d6f042009-05-18 22:20:00 +000087 const std::string &ModuleID,
Owen Anderson42253cc2009-07-01 17:00:06 +000088 llvm::raw_ostream *OS,
Owen Anderson8f1ca782009-07-01 23:14:14 +000089 llvm::LLVMContext& C);
Ted Kremenekfdfc1982007-12-19 22:24:34 +000090
Daniel Dunbar90b18272009-11-04 23:56:25 +000091/// CreateHTMLPrinter - Create an AST consumer which rewrites source code to
92/// HTML with syntax highlighting suitable for viewing in a web-browser.
93ASTConsumer *CreateHTMLPrinter(llvm::raw_ostream *OS, Preprocessor &PP,
94 bool SyntaxHighlight = true,
95 bool HighlightMacros = true);
Ted Kremenek6a340832008-03-18 21:19:49 +000096
Daniel Dunbardd63b282009-12-11 23:04:35 +000097// PCH generator: generates a precompiled header file; this file can be used
98// later with the PCHReader (clang -cc1 option -include-pch) to speed up compile
99// times.
Chris Lattnerdf961c22009-04-10 18:08:30 +0000100ASTConsumer *CreatePCHGenerator(const Preprocessor &PP,
Douglas Gregore650c8c2009-07-07 00:12:59 +0000101 llvm::raw_ostream *OS,
102 const char *isysroot = 0);
Douglas Gregor2cf26342009-04-09 22:27:44 +0000103
Eli Friedman18d868f2009-05-18 01:16:21 +0000104// Inheritance viewer: for C++ code, creates a graph of the inheritance
105// tree for the given class and displays it with "dotty".
Ted Kremenek7cae2f62008-10-23 23:36:29 +0000106ASTConsumer *CreateInheritanceViewer(const std::string& clsname);
107
Ted Kremenekbe1fe1e2009-02-17 04:27:41 +0000108} // end clang namespace
Ted Kremenekf4381fd2008-07-02 00:03:09 +0000109
Reid Spencer5f016e22007-07-11 17:01:13 +0000110#endif