aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/ASTConsumers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend/ASTConsumers.cpp')
-rw-r--r--lib/Frontend/ASTConsumers.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp
index 28834a2de8a2..26154ee2e856 100644
--- a/lib/Frontend/ASTConsumers.cpp
+++ b/lib/Frontend/ASTConsumers.cpp
@@ -1,9 +1,8 @@
//===--- ASTConsumers.cpp - ASTConsumer implementations -------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -35,10 +34,12 @@ namespace {
public:
enum Kind { DumpFull, Dump, Print, None };
- ASTPrinter(std::unique_ptr<raw_ostream> Out, Kind K, StringRef FilterString,
+ ASTPrinter(std::unique_ptr<raw_ostream> Out, Kind K,
+ ASTDumpOutputFormat Format, StringRef FilterString,
bool DumpLookups = false)
: Out(Out ? *Out : llvm::outs()), OwnedOut(std::move(Out)),
- OutputKind(K), FilterString(FilterString), DumpLookups(DumpLookups) {}
+ OutputKind(K), OutputFormat(Format), FilterString(FilterString),
+ DumpLookups(DumpLookups) {}
void HandleTranslationUnit(ASTContext &Context) override {
TranslationUnitDecl *D = Context.getTranslationUnitDecl();
@@ -91,7 +92,7 @@ namespace {
PrintingPolicy Policy(D->getASTContext().getLangOpts());
D->print(Out, Policy, /*Indentation=*/0, /*PrintInstantiation=*/true);
} else if (OutputKind != None)
- D->dump(Out, OutputKind == DumpFull);
+ D->dump(Out, OutputKind == DumpFull, OutputFormat);
}
raw_ostream &Out;
@@ -100,6 +101,9 @@ namespace {
/// How to output individual declarations.
Kind OutputKind;
+ /// What format should the output take?
+ ASTDumpOutputFormat OutputFormat;
+
/// Which declarations or DeclContexts to display.
std::string FilterString;
@@ -136,20 +140,18 @@ std::unique_ptr<ASTConsumer>
clang::CreateASTPrinter(std::unique_ptr<raw_ostream> Out,
StringRef FilterString) {
return llvm::make_unique<ASTPrinter>(std::move(Out), ASTPrinter::Print,
- FilterString);
+ ADOF_Default, FilterString);
}
std::unique_ptr<ASTConsumer>
-clang::CreateASTDumper(std::unique_ptr<raw_ostream> Out,
- StringRef FilterString,
- bool DumpDecls,
- bool Deserialize,
- bool DumpLookups) {
+clang::CreateASTDumper(std::unique_ptr<raw_ostream> Out, StringRef FilterString,
+ bool DumpDecls, bool Deserialize, bool DumpLookups,
+ ASTDumpOutputFormat Format) {
assert((DumpDecls || Deserialize || DumpLookups) && "nothing to dump");
return llvm::make_unique<ASTPrinter>(std::move(Out),
Deserialize ? ASTPrinter::DumpFull :
DumpDecls ? ASTPrinter::Dump :
- ASTPrinter::None,
+ ASTPrinter::None, Format,
FilterString, DumpLookups);
}