[PATCH] D137603: [Clang][Sema] Fix attribute((format)) bug on non-variadic functions

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 30 08:38:27 PST 2022


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! This should probably have a release note as well.



================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3896-3908
+      // If the kind is strftime, FirstArg must be 0 because strftime does not use
+      // any variadic arguments.
       S.Diag(AL.getLoc(), diag::err_format_strftime_third_parameter)
         << FirstArgExpr->getSourceRange();
       return;
+    } else if (isFunctionOrMethodVariadic(D)) {
+      // Else, if the function is variadic, then FirstArg must be 0 or the "position"
----------------
Given that we know what value we want to see there, should we emit a FixIt in these cases to adjust the format arg to the right value? (Can be done in a follow-up if you feel like doing it, I don't insist.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137603



More information about the cfe-commits mailing list