1 //===--- ASTDumper.h - Dumping implementation for ASTs --------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_AST_ASTDUMPER_H
10 #define LLVM_CLANG_AST_ASTDUMPER_H
12 #include "clang/AST/ASTNodeTraverser.h"
13 #include "clang/AST/TextNodeDumper.h"
17 class ASTDumper : public ASTNodeTraverser<ASTDumper, TextNodeDumper> {
19 TextNodeDumper NodeDumper;
23 const bool ShowColors;
26 ASTDumper(raw_ostream &OS, const comments::CommandTraits *Traits,
27 const SourceManager *SM)
28 : ASTDumper(OS, Traits, SM, SM && SM->getDiagnostics().getShowColors()) {}
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) {}
39 TextNodeDumper &doGetNodeDelegate() { return NodeDumper; }
41 void dumpLookups(const DeclContext *DC, bool DumpDecls);
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);
49 void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
50 void VisitClassTemplateDecl(const ClassTemplateDecl *D);
51 void VisitVarTemplateDecl(const VarTemplateDecl *D);