[PATCH] D78508: [Clang] Allow long as size_t printf argument on 32-bit Windows platforms.

Adrian McCarthy via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 15 09:12:20 PDT 2020


amccarth added a comment.

I'll re-iterate my opinion that the casts currently required to bypass the warnings are useful (e.g., if you ever want to port the code to 64-bit).  There are lots of places where the Windows API essentially required uncomfortable conversions, and we can't paper over all of them.  The way to get it right in all those other places is to be very aware of the underlying types.  Hiding an uncomfortable detail here and there seems like a disservice.



================
Comment at: clang/lib/AST/FormatString.cpp:407
+            if ((isSizeT() || isPtrdiffT()) &&
+                C.getTargetInfo().getTriple().isOSMSVCRT() &&
+                C.getTargetInfo().getTriple().isArch32Bit())
----------------
I'm not convinced `isOSMSVCRT` is the right check.  The troubling typedefs are [[ https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types#size-t | `SIZE_T` and `SSIZE_T` ]], which come from the Windows API and are unrelated to Microsoft's C run-time library.  I think `isOSWindows` would be more precise.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78508/new/

https://reviews.llvm.org/D78508





More information about the cfe-commits mailing list