Fix various format specifier mismatches

Format specifiers of incorrect length are replaced with format specifier
macros from `<cinttypes>` matching the typedefs used to declare the type
of the value being printed.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D89637
This commit is contained in:
Hubert Tong 2020-10-18 11:41:52 -04:00
parent f4d8e86dbe
commit 2980ce98be
3 changed files with 6 additions and 6 deletions

View File

@ -28,8 +28,8 @@
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cinttypes>
#include <cstddef> #include <cstddef>
#include <cstdint>
#include <cstring> #include <cstring>
#include <limits> #include <limits>
#include <memory> #include <memory>
@ -666,7 +666,7 @@ Error COFFObjectFile::initTLSDirectoryPtr() {
if (DataEntry->Size != DirSize) if (DataEntry->Size != DirSize)
return createStringError( return createStringError(
object_error::parse_failed, object_error::parse_failed,
"TLS Directory size (%u) is not the expected size (%u).", "TLS Directory size (%u) is not the expected size (%" PRIu64 ").",
static_cast<uint32_t>(DataEntry->Size), DirSize); static_cast<uint32_t>(DataEntry->Size), DirSize);
uintptr_t IntPtr = 0; uintptr_t IntPtr = 0;

View File

@ -939,16 +939,16 @@ void Context::printBranchInfo(const GCOVBlock &Block, uint32_t &edgeIdx,
} }
void Context::printSummary(const Summary &summary, raw_ostream &os) const { void Context::printSummary(const Summary &summary, raw_ostream &os) const {
os << format("Lines executed:%.2f%% of %u\n", os << format("Lines executed:%.2f%% of %" PRIu64 "\n",
double(summary.linesExec) * 100 / summary.lines, summary.lines); double(summary.linesExec) * 100 / summary.lines, summary.lines);
if (options.BranchInfo) { if (options.BranchInfo) {
if (summary.branches == 0) { if (summary.branches == 0) {
os << "No branches\n"; os << "No branches\n";
} else { } else {
os << format("Branches executed:%.2f%% of %u\n", os << format("Branches executed:%.2f%% of %" PRIu64 "\n",
double(summary.branchesExec) * 100 / summary.branches, double(summary.branchesExec) * 100 / summary.branches,
summary.branches); summary.branches);
os << format("Taken at least once:%.2f%% of %u\n", os << format("Taken at least once:%.2f%% of %" PRIu64 "\n",
double(summary.branchesTaken) * 100 / summary.branches, double(summary.branchesTaken) * 100 / summary.branches,
summary.branches); summary.branches);
} }

View File

@ -5560,7 +5560,7 @@ template <class ELFT> void GNUStyle<ELFT>::printDependentLibs() {
<< format_hex(Current.Offset, 1) << " contains " << SecEntries.size() << format_hex(Current.Offset, 1) << " contains " << SecEntries.size()
<< " entries:\n"; << " entries:\n";
for (NameOffset Entry : SecEntries) for (NameOffset Entry : SecEntries)
OS << " [" << format("%6tx", Entry.Offset) << "] " << Entry.Name OS << " [" << format("%6" PRIx64, Entry.Offset) << "] " << Entry.Name
<< "\n"; << "\n";
OS << "\n"; OS << "\n";
SecEntries.clear(); SecEntries.clear();