summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorColin LeMahieu <colinl@codeaurora.org>2015-03-18 18:41:23 +0000
committerColin LeMahieu <colinl@codeaurora.org>2015-03-18 18:41:23 +0000
commit916c3b423a728ec48e91e0d6e85bb570b8956da1 (patch)
tree7e9c918843a10e28544c1acf66917c0020728121 /llvm/tools/llvm-objdump/llvm-objdump.cpp
parent3294de270e86c0d060f6ca3cf43294286ae68222 (diff)
downloadbcm5719-llvm-916c3b423a728ec48e91e0d6e85bb570b8956da1.tar.gz
bcm5719-llvm-916c3b423a728ec48e91e0d6e85bb570b8956da1.zip
[Objdump] Removing size limit on DumpBytes and changing to range based for loop.
llvm-svn: 232654
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp27
1 files changed, 7 insertions, 20 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 9e51c19bd7c..365d2ff5e37 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -196,28 +196,15 @@ static const Target *getTarget(const ObjectFile *Obj = nullptr) {
void llvm::DumpBytes(StringRef bytes) {
static const char hex_rep[] = "0123456789abcdef";
- // FIXME: The real way to do this is to figure out the longest instruction
- // and align to that size before printing. I'll fix this when I get
- // around to outputting relocations.
- // 15 is the longest x86 instruction
- // 3 is for the hex rep of a byte + a space.
- // 1 is for the null terminator.
- enum { OutputSize = (15 * 3) + 1 };
- char output[OutputSize];
-
- assert(bytes.size() <= 15
- && "DumpBytes only supports instructions of up to 15 bytes");
- memset(output, ' ', sizeof(output));
- unsigned index = 0;
- for (StringRef::iterator i = bytes.begin(),
- e = bytes.end(); i != e; ++i) {
- output[index] = hex_rep[(*i & 0xF0) >> 4];
- output[index + 1] = hex_rep[*i & 0xF];
- index += 3;
+ SmallString<64> output;
+
+ for (char i: bytes) {
+ output.push_back(hex_rep[(i & 0xF0) >> 4]);
+ output.push_back(hex_rep[i & 0xF]);
+ output.push_back(' ');
}
- output[sizeof(output) - 1] = 0;
- outs() << output;
+ outs() << output.c_str();
}
bool llvm::RelocAddressLess(RelocationRef a, RelocationRef b) {
OpenPOWER on IntegriCloud