[all-commits] [llvm/llvm-project] 8e1746: [llvm-readobj] Standardize JSON output for `Other`...

Paul Kirth via All-commits all-commits at lists.llvm.org
Fri Mar 17 16:38:50 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8e1746faa3574df8fc8a3d4d26c9bff6f7859d04
      https://github.com/llvm/llvm-project/commit/8e1746faa3574df8fc8a3d4d26c9bff6f7859d04
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2023-03-17 (Fri, 17 Mar 2023)

  Changed paths:
    M llvm/test/tools/llvm-readobj/ELF/aarch64-symbols-stother.test
    M llvm/test/tools/llvm-readobj/ELF/mips-symbols-stother.test
    M llvm/test/tools/llvm-readobj/ELF/symbol-visibility.test
    M llvm/tools/llvm-readobj/ELFDumper.cpp

  Log Message:
  -----------
  [llvm-readobj] Standardize JSON output for `Other` field

Today, the LLVM output uses special handling when the Other field is 0.
This output makes sense for a command line utility that a human will
read, but JSON is a machine readable format, so being consistent is more
important. Prior to this change, any consumer of the JSON output would
need to handle the Other field specially, since the structure of the
JSON would no longer be consistent.

Changes to JSON output when Other flag == 0:
```
"Other": 0,   ->   "Other": {
                      "RawFlags": 0,
                       "Flags": []
                    },
```

There are no changes to when Other flag != 0:
```
"Other": {        ->   "Other": {
  "RawFlags": 1,          "RawFlags": 1,
  "Flags": [              "Flags": [
      ...                     ...
  ]                       ]
},                     },
```

This patch adds a overload for the JSONELFDumper's printSymbol() method,
that uses consistent output formatting, regardless of the value of the
Other field.

Depends on D137092

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D137088




More information about the All-commits mailing list