[llvm] 2980ce9 - Fix various format specifier mismatches

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 18 09:47:27 PDT 2020


Author: Hubert Tong
Date: 2020-10-18T12:39:15-04:00
New Revision: 2980ce98be117a756ec5ad485273fd5400049683

URL: https://github.com/llvm/llvm-project/commit/2980ce98be117a756ec5ad485273fd5400049683
DIFF: https://github.com/llvm/llvm-project/commit/2980ce98be117a756ec5ad485273fd5400049683.diff

LOG: 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

Added: 
    

Modified: 
    llvm/lib/Object/COFFObjectFile.cpp
    llvm/lib/ProfileData/GCOV.cpp
    llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index cd10e67af239..c0902597fadf 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -28,8 +28,8 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include <algorithm>
 #include <cassert>
+#include <cinttypes>
 #include <cstddef>
-#include <cstdint>
 #include <cstring>
 #include <limits>
 #include <memory>
@@ -666,7 +666,7 @@ Error COFFObjectFile::initTLSDirectoryPtr() {
   if (DataEntry->Size != DirSize)
     return createStringError(
         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);
 
   uintptr_t IntPtr = 0;

diff  --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index 1d8aec08c0ee..c0735250cfd8 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -939,16 +939,16 @@ void Context::printBranchInfo(const GCOVBlock &Block, uint32_t &edgeIdx,
 }
 
 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);
   if (options.BranchInfo) {
     if (summary.branches == 0) {
       os << "No branches\n";
     } else {
-      os << format("Branches executed:%.2f%% of %u\n",
+      os << format("Branches executed:%.2f%% of %" PRIu64 "\n",
                    double(summary.branchesExec) * 100 / 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,
                    summary.branches);
     }

diff  --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index 8594d717f84a..af94f14c95b1 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5560,7 +5560,7 @@ template <class ELFT> void GNUStyle<ELFT>::printDependentLibs() {
        << format_hex(Current.Offset, 1) << " contains " << SecEntries.size()
        << " entries:\n";
     for (NameOffset Entry : SecEntries)
-      OS << "  [" << format("%6tx", Entry.Offset) << "]  " << Entry.Name
+      OS << "  [" << format("%6" PRIx64, Entry.Offset) << "]  " << Entry.Name
          << "\n";
     OS << "\n";
     SecEntries.clear();


        


More information about the llvm-commits mailing list