summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-03-23 20:43:50 +0000
committerJustin Bogner <mail@justinbogner.com>2014-03-23 20:43:50 +0000
commit5ecdfc1004585b7d0a5fa026420de0f9065d73d4 (patch)
tree1cab8bd81d8d2bd23ad7995293330f87ad8fbbd7 /tools
parent77df5169a8323919b74084fb15154d9a1609f570 (diff)
downloadllvm-5ecdfc1004585b7d0a5fa026420de0f9065d73d4.tar.gz
llvm-5ecdfc1004585b7d0a5fa026420de0f9065d73d4.tar.bz2
llvm-5ecdfc1004585b7d0a5fa026420de0f9065d73d4.tar.xz
llvm-profdata: Use Format.h instead of handrolling a formatter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-profdata/llvm-profdata.cpp21
1 files changed, 2 insertions, 19 deletions
diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp
index 42783d00ff..5a0e27fd6d 100644
--- a/tools/llvm-profdata/llvm-profdata.cpp
+++ b/tools/llvm-profdata/llvm-profdata.cpp
@@ -15,6 +15,7 @@
#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/ProfileData/InstrProfWriter.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Format.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
@@ -69,24 +70,6 @@ int merge_main(int argc, const char *argv[]) {
return 0;
}
-struct HashPrinter {
- uint64_t Hash;
- HashPrinter(uint64_t Hash) : Hash(Hash) {}
- void print(raw_ostream &OS) const {
- char Buf[18], *Cur = Buf;
- *Cur++ = '0'; *Cur++ = 'x';
- for (unsigned I = 16; I;) {
- char Digit = 0xF & (Hash >> (--I * 4));
- *Cur++ = (Digit < 10 ? '0' + Digit : 'A' + Digit - 10);
- }
- OS.write(Buf, 18);
- }
-};
-static raw_ostream &operator<<(raw_ostream &OS, const HashPrinter &Hash) {
- Hash.print(OS);
- return OS;
-}
-
int show_main(int argc, const char *argv[]) {
cl::opt<std::string> Filename(cl::Positional, cl::Required,
cl::desc("<profdata-file>"));
@@ -138,7 +121,7 @@ int show_main(int argc, const char *argv[]) {
++ShownFunctions;
OS << " " << Func.Name << ":\n"
- << " Hash: " << HashPrinter(Func.Hash) << "\n"
+ << " Hash: " << format("0x%016" PRIx64, Func.Hash) << "\n"
<< " Counters: " << Func.Counts.size() << "\n"
<< " Function count: " << Func.Counts[0] << "\n";
}