[PATCH] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 6 06:05:46 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329391: Allow the creation of human-friendly ASTDumper to arbitrary output stream (authored by alexfh, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D45096?vs=141309&id=141326#toc
Repository:
rL LLVM
https://reviews.llvm.org/D45096
Files:
cfe/trunk/docs/HowToSetupToolingForLLVM.rst
cfe/trunk/include/clang/Frontend/ASTConsumers.h
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/tools/clang-check/ClangCheck.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp
Index: cfe/trunk/docs/HowToSetupToolingForLLVM.rst
===================================================================
--- cfe/trunk/docs/HowToSetupToolingForLLVM.rst
+++ cfe/trunk/docs/HowToSetupToolingForLLVM.rst
@@ -133,7 +133,8 @@
if (this->ASTList.operator _Bool())
return clang::CreateASTDeclNodeLister();
if (this->ASTDump.operator _Bool())
- return clang::CreateASTDumper(this->ASTDumpFilter);
+ return clang::CreateASTDumper(nullptr /*Dump to stdout.*/,
+ this->ASTDumpFilter);
if (this->ASTPrint.operator _Bool())
return clang::CreateASTPrinter(&llvm::outs(), this->ASTDumpFilter);
return new clang::ASTConsumer();
Index: cfe/trunk/include/clang/Frontend/ASTConsumers.h
===================================================================
--- cfe/trunk/include/clang/Frontend/ASTConsumers.h
+++ cfe/trunk/include/clang/Frontend/ASTConsumers.h
@@ -34,9 +34,10 @@
std::unique_ptr<ASTConsumer> CreateASTPrinter(std::unique_ptr<raw_ostream> OS,
StringRef FilterString);
-// AST dumper: dumps the raw AST in human-readable form to stderr; this is
-// intended for debugging.
-std::unique_ptr<ASTConsumer> CreateASTDumper(StringRef FilterString,
+// AST dumper: dumps the raw AST in human-readable form to the given output
+// stream, or stdout if OS is nullptr.
+std::unique_ptr<ASTConsumer> CreateASTDumper(std::unique_ptr<raw_ostream> OS,
+ StringRef FilterString,
bool DumpDecls, bool Deserialize,
bool DumpLookups);
Index: cfe/trunk/lib/Frontend/FrontendActions.cpp
===================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp
@@ -74,7 +74,8 @@
std::unique_ptr<ASTConsumer>
ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
- return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter,
+ return CreateASTDumper(nullptr /*Dump to stdout.*/,
+ CI.getFrontendOpts().ASTDumpFilter,
CI.getFrontendOpts().ASTDumpDecls,
CI.getFrontendOpts().ASTDumpAll,
CI.getFrontendOpts().ASTDumpLookups);
Index: cfe/trunk/lib/Frontend/ASTConsumers.cpp
===================================================================
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp
@@ -138,12 +138,14 @@
FilterString);
}
-std::unique_ptr<ASTConsumer> clang::CreateASTDumper(StringRef FilterString,
- bool DumpDecls,
- bool Deserialize,
- bool DumpLookups) {
+std::unique_ptr<ASTConsumer>
+clang::CreateASTDumper(std::unique_ptr<raw_ostream> Out,
+ StringRef FilterString,
+ bool DumpDecls,
+ bool Deserialize,
+ bool DumpLookups) {
assert((DumpDecls || Deserialize || DumpLookups) && "nothing to dump");
- return llvm::make_unique<ASTPrinter>(nullptr,
+ return llvm::make_unique<ASTPrinter>(std::move(Out),
Deserialize ? ASTPrinter::DumpFull :
DumpDecls ? ASTPrinter::Dump :
ASTPrinter::None,
Index: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
===================================================================
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp
@@ -313,7 +313,8 @@
auto &CG = *static_cast<CodeGenerator *>(ASTConsumers.back().get());
if (ShouldDumpAST)
- ASTConsumers.push_back(CreateASTDumper("", true, false, false));
+ ASTConsumers.push_back(CreateASTDumper(nullptr /*Dump to stdout.*/,
+ "", true, false, false));
CI.getDiagnosticClient().BeginSourceFile(
CI.getCompilerInstance().getLangOpts(),
Index: cfe/trunk/tools/clang-check/ClangCheck.cpp
===================================================================
--- cfe/trunk/tools/clang-check/ClangCheck.cpp
+++ cfe/trunk/tools/clang-check/ClangCheck.cpp
@@ -138,7 +138,9 @@
if (ASTList)
return clang::CreateASTDeclNodeLister();
if (ASTDump)
- return clang::CreateASTDumper(ASTDumpFilter, /*DumpDecls=*/true,
+ return clang::CreateASTDumper(nullptr /*Dump to stdout.*/,
+ ASTDumpFilter,
+ /*DumpDecls=*/true,
/*Deserialize=*/false,
/*DumpLookups=*/false);
if (ASTPrint)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45096.141326.patch
Type: text/x-patch
Size: 5020 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180406/fd74edf1/attachment-0001.bin>
More information about the cfe-commits
mailing list