1 //===--- ASTConsumers.h - ASTConsumer implementations -----------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // AST Consumers. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_CLANG_FRONTEND_ASTCONSUMERS_H 14 #define LLVM_CLANG_FRONTEND_ASTCONSUMERS_H 15 16 #include "clang/AST/ASTDumperUtils.h" 17 #include "clang/Basic/LLVM.h" 18 #include <memory> 19 20 namespace clang { 21 22 class ASTConsumer; 23 class CodeGenOptions; 24 class DiagnosticsEngine; 25 class FileManager; 26 class LangOptions; 27 class Preprocessor; 28 class TargetOptions; 29 30 // AST pretty-printer: prints out the AST in a format that is close to the 31 // original C code. The output is intended to be in a format such that 32 // clang could re-parse the output back into the same AST, but the 33 // implementation is still incomplete. 34 std::unique_ptr<ASTConsumer> CreateASTPrinter(std::unique_ptr<raw_ostream> OS, 35 StringRef FilterString); 36 37 // AST dumper: dumps the raw AST in human-readable form to the given output 38 // stream, or stdout if OS is nullptr. 39 std::unique_ptr<ASTConsumer> 40 CreateASTDumper(std::unique_ptr<raw_ostream> OS, StringRef FilterString, 41 bool DumpDecls, bool Deserialize, bool DumpLookups, 42 ASTDumpOutputFormat Format); 43 44 // AST Decl node lister: prints qualified names of all filterable AST Decl 45 // nodes. 46 std::unique_ptr<ASTConsumer> CreateASTDeclNodeLister(); 47 48 // Graphical AST viewer: for each function definition, creates a graph of 49 // the AST and displays it with the graph viewer "dotty". Also outputs 50 // function declarations to stderr. 51 std::unique_ptr<ASTConsumer> CreateASTViewer(); 52 53 } // end clang namespace 54 55 #endif 56