This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][AST] print() JSONify: Stmt implementation
ClosedPublic

Authored by Charusso on May 27 2019, 1:52 PM.

Diff Detail

Repository
rC Clang

Event Timeline

Charusso created this revision.May 27 2019, 1:52 PM
NoQ added a comment.May 27 2019, 8:18 PM

I'd prefer to keep it in the Analyzer entirely (Decls as well), as it's a fairly esoteric use case.

NoQ added inline comments.May 27 2019, 8:19 PM
clang/include/clang/Basic/JsonSupport.h
26 ↗(On Diff #201576)

inline is soo not worth typing these days.

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?

NoQ added a comment.May 28 2019, 1:49 PM

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);
}
NoQ accepted this revision.May 28 2019, 1:51 PM

I guess it's not that important though, i'm fine with committing it :)

This revision is now accepted and ready to land.May 28 2019, 1:51 PM
Charusso updated this revision to Diff 201909.May 29 2019, 7:08 AM
Charusso edited the summary of this revision. (Show Details)
  • Just rebase.
In D62494#1519981, @NoQ wrote:

Ok, how about the following:

Out << escapeOutputForJson([](raw_ostream &OS) { S->printPretty(OS, Helper, PP, /*AddQuotes=*/true); });

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.

Charusso marked an inline comment as done.May 29 2019, 10:48 AM
Charusso added inline comments.
clang/include/clang/Basic/JsonSupport.h
26 ↗(On Diff #201576)

Without that you cannot build Clang, so I will leave that.

NoQ added inline comments.May 29 2019, 10:48 AM
clang/include/clang/Basic/JsonSupport.h
26 ↗(On Diff #201576)

Mm ok nvm then >.<

NoQ added a comment.May 29 2019, 11:00 AM

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.

Ok!

Charusso set the repository for this revision to rC Clang.May 29 2019, 11:06 AM
This revision was automatically updated to reflect the committed changes.