[PATCH] D106755: Extended format string checking to wprintf/wscanf

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 30 14:51:37 PDT 2021


efriedma added subscribers: tahonermann, cor3ntin.
efriedma added inline comments.


================
Comment at: clang/lib/AST/Expr.cpp:1081
+    ArrayRef<char> AR(getTrailingObjects<char>(),
+                      getTrailingObjects<char>() + getByteLength());
+    if (llvm::convertUTF16ToUTF8String(AR, Output)) {
----------------
getStringAsChar16?


================
Comment at: clang/lib/AST/Type.cpp:1979
+    while (!Desugar->isCanonicalUnqualified()) {
+      if (Desugar.getAsString() == "char16_t") {
+        return true;
----------------
(The discussion of the typedefs on D103426 didn't really finish.)


================
Comment at: clang/lib/Lex/LiteralSupport.cpp:1923
     if (*SpellingPtr != '\\') {
       ++SpellingPtr;
       --ByteNo;
----------------
The math here probably needs to change for wide strings.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:9609
+
   size_t StrLen = std::min(std::max(TypeSize, size_t(1)) - 1, StrRef.size());
   return analyze_format_string::ParseFormatStringHasSArg(Str, Str + StrLen,
----------------
The math here looks suspicious... TypeSize is not in the same units as StrRef.size().


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

https://reviews.llvm.org/D106755



More information about the cfe-commits mailing list