Index: clang-tidy/misc/UnusedParametersCheck.cpp =================================================================== --- clang-tidy/misc/UnusedParametersCheck.cpp +++ clang-tidy/misc/UnusedParametersCheck.cpp @@ -138,8 +138,7 @@ if (Function->isExternallyVisible() || !Result.SourceManager->isInMainFile(Function->getLocation()) || !Indexer->getOtherRefs(Function).empty() || isOverrideMethod(Function)) { - SourceRange RemovalRange(Param->getLocation(), - Param->DeclaratorDecl::getSourceRange().getEnd()); + SourceRange RemovalRange(Param->getLocation(), Param->Decl::getLocation()); // Note: We always add a space before the '/*' to not accidentally create a // '*/*' for pointer types, which doesn't start a comment. clang-format will // clean this up afterwards. Index: test/clang-tidy/misc-unused-parameters.cpp =================================================================== --- test/clang-tidy/misc-unused-parameters.cpp +++ test/clang-tidy/misc-unused-parameters.cpp @@ -20,11 +20,21 @@ // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is unused [misc-unused-parameters] // CHECK-FIXES: {{^}}void c(int * /*i*/) {}{{$}} +void d(int i[]) {} +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] +// CHECK-FIXES: {{^}}void d(int /*i*/[]) {}{{$}} + +void e(int i[1]) {} +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters] +// CHECK-FIXES: {{^}}void e(int /*i*/[1]) {}{{$}} + // Unchanged cases // =============== void f(int i); // Don't remove stuff in declarations void g(int i = 1); -void h(int i) { (void)i; } // Don't remove used parameters +void h(int i[]); +void s(int i[1]); +void u(int i) { (void)i; } // Don't remove used parameters bool useLambda(int (*fn)(int)); static bool static_var = useLambda([] (int a) { return a; }); @@ -109,6 +119,9 @@ static void g(int i = 1) {} // CHECK-MESSAGES: :[[@LINE-1]]:21: warning // CHECK-FIXES: static void g(int /*i*/ = 1) {} + static void h(int i[]) {} +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning +// CHECK-FIXES: static void h(int /*i*/[]) {} }; namespace { @@ -125,6 +138,9 @@ void s(int i = 1) {} // CHECK-MESSAGES: :[[@LINE-1]]:14: warning // CHECK-FIXES: void s(int /*i*/ = 1) {} + void u(int i[]) {} +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning +// CHECK-FIXES: void u(int /*i*/[]) {} }; void C::f(int i) {} @@ -142,7 +158,8 @@ // CHECK-FIXES: c.g(); useFunction(&C::h); - useFunction(&C::s);; + useFunction(&C::s); + useFunction(&C::u); } class Base {