[llvm] r204571 - llvm-profdata: Use Format.h instead of handrolling a formatter
Justin Bogner
mail at justinbogner.com
Sun Mar 23 13:43:51 PDT 2014
Author: bogner
Date: Sun Mar 23 15:43:50 2014
New Revision: 204571
URL: http://llvm.org/viewvc/llvm-project?rev=204571&view=rev
Log:
llvm-profdata: Use Format.h instead of handrolling a formatter
Modified:
llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
Modified: llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp?rev=204571&r1=204570&r2=204571&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp (original)
+++ llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp Sun Mar 23 15:43:50 2014
@@ -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 *arg
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";
}
More information about the llvm-commits
mailing list