hokein updated this revision to Diff 49954. hokein added a comment. Use internal isOverride method.
http://reviews.llvm.org/D17926 Files: clang-tidy/misc/UnusedParametersCheck.cpp test/clang-tidy/misc-unused-parameters.cpp Index: test/clang-tidy/misc-unused-parameters.cpp =================================================================== --- test/clang-tidy/misc-unused-parameters.cpp +++ test/clang-tidy/misc-unused-parameters.cpp @@ -127,6 +127,16 @@ useFunction(&C::h); } +class Base { + virtual void f(int i); +}; + +class Derived : public Base { + void f(int i) override {} +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning +// CHECK-FIXES: void f(int /*i*/) override {} +}; + } // end namespace template <typename T> void someFunctionTemplate(T b, T e) { (void)b; (void)e; } Index: clang-tidy/misc/UnusedParametersCheck.cpp =================================================================== --- clang-tidy/misc/UnusedParametersCheck.cpp +++ clang-tidy/misc/UnusedParametersCheck.cpp @@ -76,7 +76,10 @@ // Comment out parameter name for non-local functions. if (Function->isExternallyVisible() || !Result.SourceManager->isInMainFile(Function->getLocation()) || - UsedByRef()) { + UsedByRef() || + !ast_matchers::match(cxxMethodDecl(isOverride()), *Function, + *Result.Context) + .empty()) { 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
Index: test/clang-tidy/misc-unused-parameters.cpp =================================================================== --- test/clang-tidy/misc-unused-parameters.cpp +++ test/clang-tidy/misc-unused-parameters.cpp @@ -127,6 +127,16 @@ useFunction(&C::h); } +class Base { + virtual void f(int i); +}; + +class Derived : public Base { + void f(int i) override {} +// CHECK-MESSAGES: :[[@LINE-1]]:14: warning +// CHECK-FIXES: void f(int /*i*/) override {} +}; + } // end namespace template <typename T> void someFunctionTemplate(T b, T e) { (void)b; (void)e; } Index: clang-tidy/misc/UnusedParametersCheck.cpp =================================================================== --- clang-tidy/misc/UnusedParametersCheck.cpp +++ clang-tidy/misc/UnusedParametersCheck.cpp @@ -76,7 +76,10 @@ // Comment out parameter name for non-local functions. if (Function->isExternallyVisible() || !Result.SourceManager->isInMainFile(Function->getLocation()) || - UsedByRef()) { + UsedByRef() || + !ast_matchers::match(cxxMethodDecl(isOverride()), *Function, + *Result.Context) + .empty()) { 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits