1//===--- ASTDumper.h - Dumping implementation for ASTs --------------------===// 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#ifndef LLVM_CLANG_AST_ASTDUMPER_H 10#define LLVM_CLANG_AST_ASTDUMPER_H 11 12#include "clang/AST/ASTNodeTraverser.h" 13#include "clang/AST/TextNodeDumper.h" 14 15namespace clang { 16 17class ASTDumper : public ASTNodeTraverser<ASTDumper, TextNodeDumper> { 18 19 TextNodeDumper NodeDumper; 20 21 raw_ostream &OS; 22 23 const bool ShowColors; 24 25public: 26 ASTDumper(raw_ostream &OS, const comments::CommandTraits *Traits, 27 const SourceManager *SM) 28 : ASTDumper(OS, Traits, SM, SM && SM->getDiagnostics().getShowColors()) {} 29 30 ASTDumper(raw_ostream &OS, const comments::CommandTraits *Traits, 31 const SourceManager *SM, bool ShowColors) 32 : ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {} 33 ASTDumper(raw_ostream &OS, const comments::CommandTraits *Traits, 34 const SourceManager *SM, bool ShowColors, 35 const PrintingPolicy &PrintPolicy) 36 : NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS), 37 ShowColors(ShowColors) {} 38 39 TextNodeDumper &doGetNodeDelegate() { return NodeDumper; } 40 41 void dumpLookups(const DeclContext *DC, bool DumpDecls); 42 43 template <typename SpecializationDecl> 44 void dumpTemplateDeclSpecialization(const SpecializationDecl *D, 45 bool DumpExplicitInst, bool DumpRefOnly); 46 template <typename TemplateDecl> 47 void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst); 48 49 void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D); 50 void VisitClassTemplateDecl(const ClassTemplateDecl *D); 51 void VisitVarTemplateDecl(const VarTemplateDecl *D); 52}; 53 54} // namespace clang 55 56#endif 57