[PATCH] D155641: [-Wunsafe-buffer-usage] Do not assert that function parameters have names.

Ziqing Luo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 19 10:56:32 PDT 2023


ziqingluo-90 marked an inline comment as done.
ziqingluo-90 added inline comments.


================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:1890-1891
+      // A parameter of a function definition has no name.
+      // FIXME: We should create a name for the parameter as part of the fix-it.
+      // Go through declarations of the function and look for a name?
+      if (!Parm->getIdentifier())
----------------
NoQ wrote:
> There doesn't have to be a name anywhere, and if it's not there in the definition this usually means the parameter is unused. If it's unused, we won't ever fix it, and this also means that there's no need to give it a name. So I suspect that in the typical case the correct behavior is to just preserve the anonymous parameter as-is.
> 
> This is just my usual argument: I think the fixit should simply take the part that doesn't need fixing from the original code, and include it textually. In this case this would mean duplicating the text rather than simply not touching it, but that's probably still more precise than writing code from scratch.
I think you are right.  I'll update the `FIXME` comment before land this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155641



More information about the cfe-commits mailing list