[PATCH] D28957: Fix incorrect formatting of DataRefImpl members in operator<< function

Dave Bozier via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 10:07:27 PST 2017


davidb marked 2 inline comments as done.
davidb added inline comments.


================
Comment at: include/llvm/Object/SymbolicFile.h:38
 OStream& operator<<(OStream &OS, const DataRefImpl &D) {
-  OS << "(" << format("0x%x8", D.p) << " (" << format("0x%x8", D.d.a) << ", " << format("0x%x8", D.d.b) << "))";
+  OS << "(" << format("0x%08x" PRIxPTR, D.p) << " (" << format("0x%08x", D.d.a) << ", " << format("0x%08x", D.d.b) << "))";
   return OS;
----------------
filcab wrote:
> filcab wrote:
> > Shouldn't it be `"...%" PRIxPTR`?
> > Why change the way it dumps pointers, though? Even for `uint32_t`, we're dumping as 8B. Why not always dump as 8B and be done with it?
> Since you're changing this line anyway, can you clang-format it?
> Why change the way it dumps pointers, though? Even for uint32_t, we're dumping as 8B. Why not always dump as 8B and be done with it?

Sorry, not entirely sure I understand what you are asking. I changed it because it was unable to dump a 64-bit pointer.

I intentionally tried to keep the format as close as the original intent appeared to be (minimum width of 8 characters to represent the full 32-bit field). In the case that p > 32-bit value, then the character length will of course expand....



Repository:
  rL LLVM

https://reviews.llvm.org/D28957





More information about the llvm-commits mailing list