[clang-tools-extra] [clang-tidy] modernize-use-std-format: Correct replacement types when signed stdint types are used, and when enums are printed in hex. #150343 (PR #155200)

via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 25 07:23:15 PDT 2025


================
@@ -488,9 +536,22 @@ bool FormatStringConverter::emitIntegerArgument(
            " integer type to match format"
            " specifier and StrictMode is enabled")
               .str());
-  } else if (isRealCharType(ArgType) || !ArgType->isIntegerType()) {
-    // Only specify integer if the argument is of a different type
-    FormatSpec.push_back('d');
+  } else
+  {
+    switch(ArgKind)
+    {
+      case ConversionSpecifier::Kind::xArg:
+        FormatSpec.push_back('x');
+        break;
+      case ConversionSpecifier::Kind::XArg:
+        FormatSpec.push_back('X');
+        break;
+      default:
+        if (isRealCharType(ArgType) || !ArgType->isIntegerType()) {
+        // Only specify integer if the argument is of a different type
+        FormatSpec.push_back('d');
+      }
----------------
EugeneZelenko wrote:

```suggestion
      }
      break;
```

https://github.com/llvm/llvm-project/pull/155200


More information about the cfe-commits mailing list