This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] Improve JSON output
ClosedPublic

Authored by paulkirth on Sep 28 2022, 5:11 PM.

Details

Summary

The current implementation outputs JSON in the following way:

[{'<filename>':{'FileSummary':{},...}}]

Using the filename as a key makes processing the JSON data awkward, and
should be avoided. This patch removes that outer key, since the
'FileSummary' data also includes a 'File' field, and so we lose no data.

Diff Detail

Event Timeline

paulkirth created this revision.Sep 28 2022, 5:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2022, 5:11 PM
paulkirth requested review of this revision.Sep 28 2022, 5:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2022, 5:11 PM

Another option is to replace the removed key with a 'File': <filename> key value pair. Either way will make the output easier to process.

paulkirth planned changes to this revision.Sep 28 2022, 5:24 PM

I forgot to update tests

paulkirth updated this revision to Diff 463738.Sep 28 2022, 6:30 PM

Update JSON output tests

I've added a couple of people who were involved (directly or indirectly) with this feature originally, who may have some comments.

I'm off for a week next week, and have some high priority work I need to finish off before leaving, so haven't got time to review this just yet, but will do so after I'm back.

leonardchan accepted this revision.Sep 29 2022, 10:20 AM
This revision is now accepted and ready to land.Sep 29 2022, 10:20 AM
jhenderson accepted this revision.Oct 14 2022, 12:46 AM

Functionally, this looks good, although I think it might deserve a release note, since anybody relying on the old behaviour will find their parsers stop working.

Add release notes.

@jhenderson Does the release note seem appropriate?

jhenderson accepted this revision.Oct 17 2022, 12:22 AM

LGTM, with the suggested fixes, thanks!

llvm/docs/ReleaseNotes.rst
181–183

Mostly looks good. I've rephrased it a little, an made a minor edit ot the example, to help with clarity. In the example, I've added a file extension to the filename, to make it more obviously a filename.

187

Nit: not sure you want the double blank line.

paulkirth updated this revision to Diff 468233.Oct 17 2022, 9:32 AM

Update release notes w/ reviewer feedback

paulkirth updated this revision to Diff 468234.Oct 17 2022, 9:32 AM

Remove extra newline

This revision was landed with ongoing or failed builds.Oct 17 2022, 9:43 AM
This revision was automatically updated to reflect the committed changes.