[PATCH] D45096: Allow the creation of human-friendly ASTDumper to arbitrary output stream

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 5 12:10:49 PDT 2018


whisperity updated this revision to Diff 141194.
whisperity added a comment.

- Overload removed, now only one `CreateASTDumper` function remains.
- Updated the call sites of this function to use this call.


Repository:
  rC Clang

https://reviews.llvm.org/D45096

Files:
  docs/HowToSetupToolingForLLVM.rst
  include/clang/Frontend/ASTConsumers.h
  lib/Frontend/ASTConsumers.cpp
  lib/Frontend/FrontendActions.cpp
  tools/clang-check/ClangCheck.cpp
  tools/clang-import-test/clang-import-test.cpp


Index: tools/clang-import-test/clang-import-test.cpp
===================================================================
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -313,7 +313,7 @@
   auto &CG = *static_cast<CodeGenerator *>(ASTConsumers.back().get());
 
   if (ShouldDumpAST)
-    ASTConsumers.push_back(CreateASTDumper("", true, false, false));
+    ASTConsumers.push_back(CreateASTDumper(nullptr, "", true, false, false));
 
   CI.getDiagnosticClient().BeginSourceFile(
       CI.getCompilerInstance().getLangOpts(),
Index: tools/clang-check/ClangCheck.cpp
===================================================================
--- tools/clang-check/ClangCheck.cpp
+++ tools/clang-check/ClangCheck.cpp
@@ -138,7 +138,8 @@
     if (ASTList)
       return clang::CreateASTDeclNodeLister();
     if (ASTDump)
-      return clang::CreateASTDumper(ASTDumpFilter, /*DumpDecls=*/true,
+      return clang::CreateASTDumper(nullptr, ASTDumpFilter,
+                                    /*DumpDecls=*/true,
                                     /*Deserialize=*/false,
                                     /*DumpLookups=*/false);
     if (ASTPrint)
Index: lib/Frontend/FrontendActions.cpp
===================================================================
--- lib/Frontend/FrontendActions.cpp
+++ 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,
+                         CI.getFrontendOpts().ASTDumpFilter,
                          CI.getFrontendOpts().ASTDumpDecls,
                          CI.getFrontendOpts().ASTDumpAll,
                          CI.getFrontendOpts().ASTDumpLookups);
Index: lib/Frontend/ASTConsumers.cpp
===================================================================
--- lib/Frontend/ASTConsumers.cpp
+++ 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: include/clang/Frontend/ASTConsumers.h
===================================================================
--- include/clang/Frontend/ASTConsumers.h
+++ 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.
+std::unique_ptr<ASTConsumer> CreateASTDumper(std::unique_ptr<raw_ostream> OS,
+                                             StringRef FilterString,
                                              bool DumpDecls, bool Deserialize,
                                              bool DumpLookups);
 
Index: docs/HowToSetupToolingForLLVM.rst
===================================================================
--- docs/HowToSetupToolingForLLVM.rst
+++ docs/HowToSetupToolingForLLVM.rst
@@ -133,7 +133,7 @@
       if (this->ASTList.operator _Bool())
           return clang::CreateASTDeclNodeLister();
       if (this->ASTDump.operator _Bool())
-          return clang::CreateASTDumper(this->ASTDumpFilter);
+          return clang::CreateASTDumper(nullptr, this->ASTDumpFilter);
       if (this->ASTPrint.operator _Bool())
           return clang::CreateASTPrinter(&llvm::outs(), this->ASTDumpFilter);
       return new clang::ASTConsumer();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45096.141194.patch
Type: text/x-patch
Size: 4610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180405/98cae65b/attachment.bin>


More information about the cfe-commits mailing list