diff options
author | Georgii Rymar <grimar@accesssoftek.com> | 2020-11-06 13:39:55 +0300 |
---|---|---|
committer | Georgii Rymar <grimar@accesssoftek.com> | 2020-11-18 11:31:00 +0300 |
commit | 65fd17c241e22e1671e81efdb683687369c2feb3 (patch) | |
tree | 35b2b8a7ecd72cc4cb8d7254410a5a3f1ca313c8 /llvm/lib/Support/YAMLTraits.cpp | |
parent | test commit (diff) | |
download | llvm-project-65fd17c241e22e1671e81efdb683687369c2feb3.tar.gz llvm-project-65fd17c241e22e1671e81efdb683687369c2feb3.tar.bz2 llvm-project-65fd17c241e22e1671e81efdb683687369c2feb3.zip |
[lib/Support/YAMLTraits] - Don't print leading zeroes when dumping Hex8/Hex16/Hex32 types.
When we produce an YAML output, we also print leading zeroes currently.
An output might look like this:
```
- Name: .dynsym
Type: SHT_DYNSYM
Address: 0x0000000000001000
EntSize: 0x0000000000000018
```
There are probably no reason to print leading zeroes.
It just makes harder to read values. This patch stops printing them.
The output becomes like:
```
- Name: .dynsym
Type: SHT_DYNSYM
Address: 0x1000
EntSize: 0x18
```
This affects obj2yaml mostly, but also dsymutil and llvm-xray tools output.
Differential revision: https://reviews.llvm.org/D90930
Diffstat (limited to 'llvm/lib/Support/YAMLTraits.cpp')
-rw-r--r-- | llvm/lib/Support/YAMLTraits.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp index df5e2cee7a0a..1b5c79f6b592 100644 --- a/llvm/lib/Support/YAMLTraits.cpp +++ b/llvm/lib/Support/YAMLTraits.cpp @@ -1046,8 +1046,7 @@ StringRef ScalarTraits<float>::input(StringRef Scalar, void *, float &Val) { } void ScalarTraits<Hex8>::output(const Hex8 &Val, void *, raw_ostream &Out) { - uint8_t Num = Val; - Out << format("0x%02X", Num); + Out << format("0x%" PRIX8, (uint8_t)Val); } StringRef ScalarTraits<Hex8>::input(StringRef Scalar, void *, Hex8 &Val) { @@ -1061,8 +1060,7 @@ StringRef ScalarTraits<Hex8>::input(StringRef Scalar, void *, Hex8 &Val) { } void ScalarTraits<Hex16>::output(const Hex16 &Val, void *, raw_ostream &Out) { - uint16_t Num = Val; - Out << format("0x%04X", Num); + Out << format("0x%" PRIX16, (uint16_t)Val); } StringRef ScalarTraits<Hex16>::input(StringRef Scalar, void *, Hex16 &Val) { @@ -1076,8 +1074,7 @@ StringRef ScalarTraits<Hex16>::input(StringRef Scalar, void *, Hex16 &Val) { } void ScalarTraits<Hex32>::output(const Hex32 &Val, void *, raw_ostream &Out) { - uint32_t Num = Val; - Out << format("0x%08X", Num); + Out << format("0x%" PRIX32, (uint32_t)Val); } StringRef ScalarTraits<Hex32>::input(StringRef Scalar, void *, Hex32 &Val) { @@ -1091,8 +1088,7 @@ StringRef ScalarTraits<Hex32>::input(StringRef Scalar, void *, Hex32 &Val) { } void ScalarTraits<Hex64>::output(const Hex64 &Val, void *, raw_ostream &Out) { - uint64_t Num = Val; - Out << format("0x%016llX", Num); + Out << format("0x%" PRIX64, (uint64_t)Val); } StringRef ScalarTraits<Hex64>::input(StringRef Scalar, void *, Hex64 &Val) { |