misc-unused-parameters: Properly handle static class members.

Not sure why I wrote what I wrote before.

llvm-svn: 243403
This commit is contained in:
Daniel Jasper 2015-07-28 10:39:25 +00:00
parent 78ee5cc8e1
commit 718029ba6b
2 changed files with 10 additions and 3 deletions

View File

@ -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;

View File

@ -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: