[PATCH] D103426: Clang: Extend format string checking to wprintf/wscanf

Marcus Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 23 19:41:30 PDT 2021


MarcusJohnson91 updated this revision to Diff 361405.
MarcusJohnson91 marked an inline comment as done.
MarcusJohnson91 added a comment.

Just implemented the change Aaron requested in TemplateBase.cpp


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

https://reviews.llvm.org/D103426

Files:
  clang/lib/AST/TemplateBase.cpp


Index: clang/lib/AST/TemplateBase.cpp
===================================================================
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -74,14 +74,7 @@
 
   if (Policy.MSVCFormatting)
     IncludeType = false;
-  
-  const Decl *D = nullptr;
-  if (T->isTypedefNameType()) {
-    D = T->getAs<TypedefType>()->getDecl();
-  }
     
-  
-
   if (T->isBooleanType()) {
     if (!Policy.MSVCFormatting)
       Out << (Val.getBoolValue() ? "true" : "false");
@@ -95,15 +88,15 @@
         Out << "(unsigned char)";
     }
     CharacterLiteral::print(Val.getZExtValue(), CharacterLiteral::Ascii, Out);
-  } else if (D != nullptr && T->isAnyCharacterType(D->getLangOpts()) && !Policy.MSVCFormatting) {
+  } else if (T->isAnyCharacterType(T->getAs<TypedefType>()->getDecl()->getLangOpts()) && !Policy.MSVCFormatting) {
     CharacterLiteral::CharacterKind Kind;
     if (T->isWideCharType())
       Kind = CharacterLiteral::Wide;
     else if (T->isChar8Type())
       Kind = CharacterLiteral::UTF8;
-    else if (T->isChar16Type(D->getLangOpts()))
+    else if (T->isChar16Type(T->getAs<TypedefType>()->getDecl()->getLangOpts()))
       Kind = CharacterLiteral::UTF16;
-    else if (T->isChar32Type(D->getLangOpts()))
+    else if (T->isChar32Type(T->getAs<TypedefType>()->getDecl()->getLangOpts()))
       Kind = CharacterLiteral::UTF32;
     else
       Kind = CharacterLiteral::Ascii;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103426.361405.patch
Type: text/x-patch
Size: 1424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210724/78d6f772/attachment.bin>


More information about the llvm-commits mailing list