summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTConsumers.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2018-04-06 13:01:12 +0000
committerAlexander Kornienko <alexfh@google.com>2018-04-06 13:01:12 +0000
commitd10d7900449db3a9d12cea2e670199aceec6ec3a (patch)
treefc60bfc10f6d25ecc54880be3121fb9ae5cb7438 /clang/lib/Frontend/ASTConsumers.cpp
parent5334a2c5715b772b67eeb33165e5a3654a81f011 (diff)
downloadbcm5719-llvm-d10d7900449db3a9d12cea2e670199aceec6ec3a.tar.gz
bcm5719-llvm-d10d7900449db3a9d12cea2e670199aceec6ec3a.zip
Allow the creation of human-friendly ASTDumper to arbitrary output stream
Summary: `ASTPrinter` allows setting the ouput to any O-Stream, but that printer creates source-code-like syntax (and is also marked with a `FIXME`). The nice, colourful, mostly human-readable `ASTDumper` only works on the standard output, which is not feasible in case a user wants to see the AST of a file through a code navigation/comprehension tool. This small addition of an overload solves generating a nice colourful AST block for the users of a tool I'm working on, [[ http://github.com/Ericsson/CodeCompass | CodeCompass ]], as opposed to having to duplicate the behaviour of definitions that only exist in the anonymous namespace of implementation TUs related to this module. Reviewers: alexfh, klimek, rsmith Reviewed By: alexfh Subscribers: rnkovacs, dkrupp, gsd, xazax.hun, cfe-commits, #clang Tags: #clang Patch by Whisperity! Differential Revision: https://reviews.llvm.org/D45096 llvm-svn: 329391
Diffstat (limited to 'clang/lib/Frontend/ASTConsumers.cpp')
-rw-r--r--clang/lib/Frontend/ASTConsumers.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Frontend/ASTConsumers.cpp b/clang/lib/Frontend/ASTConsumers.cpp
index 7dc475e26f7..a51d5b4a151 100644
--- a/clang/lib/Frontend/ASTConsumers.cpp
+++ b/clang/lib/Frontend/ASTConsumers.cpp
@@ -138,12 +138,14 @@ clang::CreateASTPrinter(std::unique_ptr<raw_ostream> Out,
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,
OpenPOWER on IntegriCloud