[llvm] r215196 - llvm-objdump: use portable format specifiers for info.

Sean Silva chisophugis at gmail.com
Fri Aug 8 12:17:23 PDT 2014


A lot of these use cases could be handled by a tiny helper class Hex such
that `OS << Hex(84);` formats in hex (also ideally supporting something
like `OS << Hex(84, /*Width=*/8);`).

YAMLIO has a class like that a class for its output (but I think it is
YAMLIO specific)

-- Sean Silva


On Fri, Aug 8, 2014 at 5:00 AM, Tim Northover <tnorthover at apple.com> wrote:

> Author: tnorthover
> Date: Fri Aug  8 07:00:09 2014
> New Revision: 215196
>
> URL: http://llvm.org/viewvc/llvm-project?rev=215196&view=rev
> Log:
> llvm-objdump: use portable format specifiers for info.
>
> ARM bots (& others, I think, now that I look) were failing because we
> were using incorrect printf-style format specifiers. They were wrong
> on almost any platform, actually, just mostly harmlessly so.
>
> Modified:
>     llvm/trunk/tools/llvm-objdump/MachODump.cpp
>
> Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=215196&r1=215195&r2=215196&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
> +++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Fri Aug  8 07:00:09 2014
> @@ -629,27 +629,27 @@ printMachOCompactUnwindSection(const Mac
>    // Finally, we're ready to print the data we've gathered.
>    outs() << "Contents of __compact_unwind section:\n";
>    for (auto &Entry : CompactUnwinds) {
> -    outs() << "  Entry at offset " << format("0x%x",
> Entry.OffsetInSection)
> +    outs() << "  Entry at offset " << format("0x" PRIx32,
> Entry.OffsetInSection)
>             << ":\n";
>
>      // 1. Start of the region this entry applies to.
>      outs() << "    start:                "
> -           << format("0x%x", Entry.FunctionAddr) << ' ';
> +           << format("0x%" PRIx64, Entry.FunctionAddr) << ' ';
>      printUnwindRelocDest(Obj, Symbols, Entry.FunctionReloc,
>                           Entry.FunctionAddr);
>      outs() << '\n';
>
>      // 2. Length of the region this entry applies to.
>      outs() << "    length:               "
> -           << format("0x%x", Entry.Length) << '\n';
> +           << format("0x%" PRIx32, Entry.Length) << '\n';
>      // 3. The 32-bit compact encoding.
>      outs() << "    compact encoding:     "
> -           << format("0x%08x", Entry.CompactEncoding) << '\n';
> +           << format("0x%08" PRIx32, Entry.CompactEncoding) << '\n';
>
>      // 4. The personality function, if present.
>      if (Entry.PersonalityReloc.getObjectFile()) {
>        outs() << "    personality function: "
> -             << format("0x%x", Entry.PersonalityAddr) << ' ';
> +             << format("0x%" PRIx64, Entry.PersonalityAddr) << ' ';
>        printUnwindRelocDest(Obj, Symbols, Entry.PersonalityReloc,
>                             Entry.PersonalityAddr);
>        outs() << '\n';
> @@ -658,7 +658,7 @@ printMachOCompactUnwindSection(const Mac
>      // 5. This entry's language-specific data area.
>      if (Entry.LSDAReloc.getObjectFile()) {
>        outs() << "    LSDA:                 "
> -             << format("0x%x", Entry.LSDAAddr) << ' ';
> +             << format("0x%" PRIx64, Entry.LSDAAddr) << ' ';
>        printUnwindRelocDest(Obj, Symbols, Entry.LSDAReloc, Entry.LSDAAddr);
>        outs() << '\n';
>      }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140808/cc6cbac1/attachment.html>


More information about the llvm-commits mailing list