diff options
Diffstat (limited to 'clang/lib/AST/StmtPrinter.cpp')
-rw-r--r-- | clang/lib/AST/StmtPrinter.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index b06edb4b6db..7fe0be5217d 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -36,6 +36,7 @@ #include "clang/Basic/CharInfo.h" #include "clang/Basic/ExpressionTraits.h" #include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/JsonSupport.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/Lambda.h" #include "clang/Basic/OpenMPKinds.h" @@ -2395,12 +2396,21 @@ void Stmt::dumpPretty(const ASTContext &Context) const { printPretty(llvm::errs(), nullptr, PrintingPolicy(Context.getLangOpts())); } -void Stmt::printPretty(raw_ostream &OS, PrinterHelper *Helper, +void Stmt::printPretty(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation, - StringRef NL, - const ASTContext *Context) const { - StmtPrinter P(OS, Helper, Policy, Indentation, NL, Context); - P.Visit(const_cast<Stmt*>(this)); + StringRef NL, const ASTContext *Context) const { + StmtPrinter P(Out, Helper, Policy, Indentation, NL, Context); + P.Visit(const_cast<Stmt *>(this)); +} + +void Stmt::printJson(raw_ostream &Out, PrinterHelper *Helper, + const PrintingPolicy &Policy, bool AddQuotes) const { + std::string Buf; + llvm::raw_string_ostream TempOut(Buf); + + printPretty(TempOut, Helper, Policy); + + Out << JsonFormat(TempOut.str(), AddQuotes); } //===----------------------------------------------------------------------===// |