]> granicus.if.org Git - llvm/commitdiff
[llvm-objdump] Don't print trailing space in dumpBytes
authorFangrui Song <maskray@google.com>
Wed, 10 Apr 2019 05:31:21 +0000 (05:31 +0000)
committerFangrui Song <maskray@google.com>
Wed, 10 Apr 2019 05:31:21 +0000 (05:31 +0000)
In disassembly output, dumpBytes prints a space, followed by a tab
printed by printInstr. Remove the extra space.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358045 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCInstPrinter.cpp
tools/llvm-objdump/llvm-objdump.cpp

index ab8773e7bbb2fa1ed5e18407ac428cd5e453518e..159f4070fe9f92cf41588110d1784d0d16622d6f 100644 (file)
@@ -21,10 +21,14 @@ using namespace llvm;
 
 void llvm::dumpBytes(ArrayRef<uint8_t> bytes, raw_ostream &OS) {
   static const char hex_rep[] = "0123456789abcdef";
+  bool First = true;
   for (char i: bytes) {
+    if (First)
+      First = false;
+    else
+      OS << ' ';
     OS << hex_rep[(i & 0xF0) >> 4];
     OS << hex_rep[i & 0xF];
-    OS << ' ';
   }
 }
 
index ceefe47404db380060c624285da731448665ac21..3ae72c7150118b61165e2d3215db47f59bb97d54 100644 (file)
@@ -614,7 +614,7 @@ public:
     if (MI)
       IP.printInst(MI, OS, "", STI);
     else
-      OS << " <unknown>";
+      OS << "\t<unknown>";
   }
 };
 PrettyPrinter PrettyPrinterInst;
@@ -629,7 +629,7 @@ public:
     if (!NoShowRawInsn) {
       OS << "\t";
       dumpBytes(Bytes.slice(0, 4), OS);
-      OS << format("%08" PRIx32, opcode);
+      OS << format("\t%08" PRIx32, opcode);
     }
   }
   void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef<uint8_t> Bytes,
@@ -768,7 +768,7 @@ public:
     if (MI)
       IP.printInst(MI, OS, "", STI);
     else
-      OS << " <unknown>";
+      OS << "\t<unknown>";
   }
 };
 BPFPrettyPrinter BPFPrettyPrinterInst;