diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp --- a/clang/lib/Analysis/UnsafeBufferUsage.cpp +++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp @@ -1885,9 +1885,12 @@ const ParmVarDecl *Parm = FD->getParamDecl(i); if (Parm->isImplicit()) - continue; - assert(Parm->getIdentifier() && - "A parameter of a function definition has no name"); + continue; + // FIXME: If a parameter has no name, it is unused in the + // definition. So we could just leave it as it is. + if (!Parm->getIdentifier()) + // If a parameter of a function definition has no name: + return std::nullopt; if (i == ParmIdx) // This is our spanified paramter! SS << NewTypeText.str() << "(" << Parm->getIdentifier()->getName().str() << ", " diff --git a/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp b/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp --- a/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp +++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-parm-span.cpp @@ -156,4 +156,9 @@ if (++MyName){} } +// CHECK-NOT: fix-it:{{.*}}: +void parmHasNoName(int *p, int *) { // cannot fix the function because there is one parameter has no name. + p[5] = 5; +} + #endif