[clang-tools-extra] r336283 - [clang-tidy] Fix http://llvm.org/PR38055
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 4 08:19:49 PDT 2018
Author: alexfh
Date: Wed Jul 4 08:19:49 2018
New Revision: 336283
URL: http://llvm.org/viewvc/llvm-project?rev=336283&view=rev
Log:
[clang-tidy] Fix http://llvm.org/PR38055
Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp?rev=336283&r1=336282&r2=336283&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp Wed Jul 4 08:19:49 2018
@@ -159,8 +159,9 @@ void UnusedParametersCheck::warnOnUnused
MyDiag << removeParameter(Result, FD, ParamIndex);
// Fix all call sites.
- for (const auto *Call : Indexer->getFnCalls(Function))
- MyDiag << removeArgument(Result, Call, ParamIndex);
+ for (const CallExpr *Call : Indexer->getFnCalls(Function))
+ if (ParamIndex < Call->getNumArgs()) // See PR38055 for example.
+ MyDiag << removeArgument(Result, Call, ParamIndex);
}
void UnusedParametersCheck::check(const MatchFinder::MatchResult &Result) {
Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp?rev=336283&r1=336282&r2=336283&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp Wed Jul 4 08:19:49 2018
@@ -222,6 +222,21 @@ static Function<void(int, int i)> dontGe
return Function<void(int, int)>();
}
+namespace PR38055 {
+namespace {
+struct a {
+ void b(int c) {;}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: parameter 'c' is unused
+// CHECK-FIXES: {{^}} void b() {;}{{$}}
+};
+template <class>
+class d {
+ a e;
+ void f() { e.b(); }
+};
+} // namespace
+} // namespace PR38055
+
namespace strict_mode_off {
// Do not warn on empty function bodies.
void f1(int foo1) {}
More information about the cfe-commits
mailing list