Subzero: Remove a couple clumsy uses of snprintf.
We can use llvm::format() to achieve the same result in these cases.
BUG= none
R=jpp@chromium.org, kschimpf@google.com
Review URL: https://codereview.chromium.org/1866633003 .
diff --git a/src/IceInst.cpp b/src/IceInst.cpp
index a30a632..8412b05 100644
--- a/src/IceInst.cpp
+++ b/src/IceInst.cpp
@@ -22,6 +22,8 @@
#include "IceOperand.h"
#include "IceTargetLowering.h"
+#include "llvm/Support/Format.h"
+
namespace Ice {
namespace {
@@ -626,13 +628,11 @@
if (!Func->isVerbose(IceV_Deleted) && (isDeleted() || isRedundantAssign()))
return;
if (Func->isVerbose(IceV_InstNumbers)) {
- char buf[30];
InstNumberT Number = getNumber();
if (Number == NumberDeleted)
- snprintf(buf, llvm::array_lengthof(buf), "[XXX]");
+ Str << "[XXX]";
else
- snprintf(buf, llvm::array_lengthof(buf), "[%3d]", Number);
- Str << buf;
+ Str << llvm::format("[%3d]", Number);
}
Str << " ";
if (isDeleted())
diff --git a/src/IceTimerTree.cpp b/src/IceTimerTree.cpp
index 6cba289..ccc7788 100644
--- a/src/IceTimerTree.cpp
+++ b/src/IceTimerTree.cpp
@@ -22,6 +22,7 @@
#pragma clang diagnostic ignored "-Wunused-parameter"
#endif // __clang__
+#include "llvm/Support/Format.h"
#include "llvm/Support/Timer.h"
#ifdef __clang__
@@ -231,10 +232,8 @@
if (!BuildDefs::timers())
return;
for (auto &I : reverse_range(Map)) {
- char buf[80];
- snprintf(buf, llvm::array_lengthof(buf), " %10.6f (%4.1f%%): ", I.first,
- I.first * 100 / TotalTime);
- Str << buf << I.second << "\n";
+ Str << llvm::format(" %10.6f (%4.1f%%): ", I.first,
+ I.first * 100 / TotalTime) << I.second << "\n";
}
}