This patch also adds a function called JsonFormat() which:
- Flattens the string so removes the new-lines.
- Escapes double quotes.
Paths
| Differential D62494
[analyzer][AST] print() JSONify: Stmt implementation ClosedPublic Authored by Charusso on May 27 2019, 1:52 PM.
Details Summary This patch also adds a function called JsonFormat() which:
Diff Detail
Event TimelineHerald added subscribers: dkrupp, donat.nagy, mikhail.ramalho and 3 others. · View Herald TranscriptMay 27 2019, 1:52 PM Charusso added a child revision: D62495: [analyzer] print() JSONify: Decl revision.May 27 2019, 1:55 PM Comment Actions I'd prefer to keep it in the Analyzer entirely (Decls as well), as it's a fairly esoteric use case.
Comment Actions I have not found any better place and Decl-printing has more and more esoteric version with crazy boolean flags. Where would you move that? Comment Actions Ok, how about the following: Out << escapeOutputForJson([](raw_ostream &OS) { S->printPretty(OS, Helper, PP, /*AddQuotes=*/true); }); Where escapeOutputForJson() is defined in JsonSupport.h as something like: std::string escapeOutputForJson(std::function<void(raw_ostream &)> Func) { std::string Buf; llvm::raw_string_ostream TempOut(Buf); Func(TempOut); Out << JsonFormat(TempOut.str(), AddQuotes); } This revision is now accepted and ready to land.May 28 2019, 1:51 PM Comment Actions
When you wrote your idea that was my first idea as well as it is very common in the Static Analyzer, but our job is to make the life more simple.
Comment Actions
Ok! Closed by commit rC362000: [analyzer][AST] print() JSONify: Stmt implementation (authored by Charusso). · Explain WhyMay 29 2019, 11:14 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 201996 include/clang/AST/Stmt.h
include/clang/Basic/JsonSupport.h
lib/AST/StmtPrinter.cpp
lib/Analysis/ProgramPoint.cpp
lib/StaticAnalyzer/Core/Environment.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp
|