diff --git a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp index 02cb6216e38c..18e39609f0ed 100644 --- a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp @@ -70,10 +70,11 @@ void UnusedParametersCheck::warnOnUnusedParameter( }; // Comment out parameter name for non-local functions. - if ((Function->isExternallyVisible() && - Function->getStorageClass() != StorageClass::SC_Static) || - UsedByRef()) { + if (Function->isExternallyVisible() || UsedByRef()) { SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd()); + // 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. MyDiag << FixItHint::CreateReplacement( RemovalRange, (Twine(" /*") + Param->getName() + "*/").str()); return; diff --git a/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp b/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp index e017128d5d97..7d3c37d64452 100644 --- a/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-unused-parameters.cpp @@ -57,6 +57,12 @@ static void someCallSites() { staticFunctionE(); } +class SomeClass { + static void f(int i) {} +// CHECK-MESSAGES: :[[@LINE-1]]:21: warning +// CHECK-FIXES: static void f(int /*i*/) {} +}; + namespace { class C { public: