[PATCH] Analysis: Add support for MS specific printf format specifiers
Jordan Rose
jordan_rose at apple.com
Wed Aug 21 09:24:13 PDT 2013
This is included in [PR13565](http://llvm.org/bugs/show_bug.cgi?id=13565), so you can track your progress there.
================
Comment at: lib/Analysis/FormatString.cpp:240
@@ +239,3 @@
+ I += 3;
+ lmKind = LengthModifier::AsInt64;
+ break;
----------------
Typo: AsInt32.
================
Comment at: lib/Analysis/ScanfFormatString.cpp:368
@@ -362,1 +367,3 @@
+ case LengthModifier::AsInt3264:
+ case LengthModifier::AsInt64:
return ArgType::Invalid();
----------------
>From what I read at http://msdn.microsoft.com/en-us/library/kwwtf9ch(v=vs.71).aspx, `%I64n` is technically valid.
================
Comment at: lib/Analysis/PrintfFormatString.cpp:367-369
@@ -353,2 +366,5 @@
case LengthModifier::AsMAllocate:
+ case LengthModifier::AsInt32:
+ case LengthModifier::AsInt3264:
+ case LengthModifier::AsInt64:
return ArgType::Invalid();
----------------
It seems like all of these are valid, just not enabled by default.
================
Comment at: lib/Analysis/PrintfFormatString.cpp:325-328
@@ -315,2 +324,6 @@
return ArgType(Ctx.getSizeType(), "size_t");
+ case LengthModifier::AsInt3264:
+ return Ctx.getTargetInfo().getTriple().isArch64Bit()
+ ? Ctx.UnsignedLongLongTy
+ : Ctx.UnsignedIntTy;
case LengthModifier::AsPtrDiff:
----------------
I think just matching AsSizeT here is probably fine, per http://msdn.microsoft.com/en-us/library/tcxf1dw6(v=vs.90).aspx
================
Comment at: lib/Analysis/PrintfFormatString.cpp:313
@@ -306,1 +312,3 @@
+ case LengthModifier::AsInt32:
+ return Ctx.UnsignedIntTy;
case LengthModifier::AsChar: return Ctx.UnsignedCharTy;
----------------
I don't know if Windows has any ILP64 configurations, but this might need to actually look for "unsigned __int32". At the very least it should use it in the name like "uintmax_t".
(I'm doing my comments backwards, so all of this applies to the signed integers as well.)
================
Comment at: lib/Analysis/PrintfFormatString.cpp:319
@@ -310,2 +318,3 @@
case LengthModifier::AsQuad:
+ case LengthModifier::AsInt64:
return Ctx.UnsignedLongLongTy;
----------------
Ditto -- this should be "unsigned __int64".
================
Comment at: lib/Analysis/FormatString.cpp:544-546
@@ -516,5 +543,5 @@
- // MacOS X unicode extensions.
+ // POSIX unicode extensions.
case CArg: return "C";
case SArg: return "S";
----------------
Huh, I didn't realize these were present elsewhere. They don't quite behave the same on Windows, right? See http://llvm.org/bugs/show_bug.cgi?id=13565
================
Comment at: include/clang/Analysis/Analyses/FormatString.h:77
@@ +76,3 @@
+ AsInt32, // 'I32' (MSVCRT, like __int32)
+ AsInt3264, // 'I' (MSVCRT, like size_t/ptrdiff_t)
+ AsInt64, // 'I64' (MSVCRT, like __int64)
----------------
I don't like this name. How about AsIntWord or something? (As I understand it "word" is an overloaded term in MSVC, though.)
http://llvm-reviews.chandlerc.com/D1456
More information about the cfe-commits
mailing list