[clang-tools-extra] r342458 - [clang-tidy] use CHECK-NOTES in tests for bugprone-argument-comment

Jonas Toth via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 18 03:15:15 PDT 2018


Author: jonastoth
Date: Tue Sep 18 03:15:15 2018
New Revision: 342458

URL: http://llvm.org/viewvc/llvm-project?rev=342458&view=rev
Log:
[clang-tidy] use CHECK-NOTES in tests for bugprone-argument-comment

Summary:
This patch uses CHECK-NOTES for the tests.
Its part of an effort to test *ALL* generated diagnostics in clang-tidy,
as emitted notes were previously ignored.

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Differential Revision: https://reviews.llvm.org/D52178

Modified:
    clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-gmock.cpp
    clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-strict.cpp
    clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-gmock.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-gmock.cpp?rev=342458&r1=342457&r2=342458&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-gmock.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-gmock.cpp Tue Sep 18 03:15:15 2018
@@ -83,17 +83,41 @@ class MockStandalone {
 void test_gmock_expectations() {
   MockDerived m;
   EXPECT_CALL(m, Method(/*param_one=*/1, /*param_tw=*/2));
-// CHECK-MESSAGES: [[@LINE-1]]:42: warning: argument name 'param_tw' in comment does not match parameter name 'param_two'
+// CHECK-NOTES: [[@LINE-1]]:42: warning: argument name 'param_tw' in comment does not match parameter name 'param_two'
+// CHECK-NOTES: [[@LINE-2]]:42: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-19]]:42: note: 'param_two' declared here
+// CHECK-NOTES: [[@LINE-15]]:3: note: actual callee ('gmock_Method') is declared here
+// CHECK-NOTES: [[@LINE-33]]:30: note: expanded from macro 'MOCK_METHOD2'
+// CHECK-NOTES: [[@LINE-36]]:7: note: expanded from macro 'GMOCK_METHOD2_'
+// CHECK-NOTES: note: expanded from here
 // CHECK-FIXES:   EXPECT_CALL(m, Method(/*param_one=*/1, /*param_two=*/2));
   EXPECT_CALL(m, Method2(/*p_on=*/3, /*p_two=*/4));
-// CHECK-MESSAGES: [[@LINE-1]]:26: warning: argument name 'p_on' in comment does not match parameter name 'p_one'
+// CHECK-NOTES: [[@LINE-1]]:26: warning: argument name 'p_on' in comment does not match parameter name 'p_one'
+// CHECK-NOTES: [[@LINE-2]]:26: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-27]]:28: note: 'p_one' declared here
+// CHECK-NOTES: [[@LINE-23]]:3: note: actual callee ('gmock_Method2') is declared here
+// CHECK-NOTES: [[@LINE-41]]:36: note: expanded from macro 'MOCK_CONST_METHOD2'
+// CHECK-NOTES: [[@LINE-45]]:7: note: expanded from macro 'GMOCK_METHOD2_'
+// CHECK-NOTES: note: expanded from here
 // CHECK-FIXES:   EXPECT_CALL(m, Method2(/*p_one=*/3, /*p_two=*/4));
 
   #define PARAM1 11
   #define PARAM2 22
   EXPECT_CALL(m, Method2(/*p_on1=*/PARAM1, /*p_tw2=*/PARAM2));
-// CHECK-MESSAGES: [[@LINE-1]]:26: warning: argument name 'p_on1' in comment does not match parameter name 'p_one'
-// CHECK-MESSAGES: [[@LINE-2]]:44: warning: argument name 'p_tw2' in comment does not match parameter name 'p_two'
+// CHECK-NOTES: [[@LINE-1]]:26: warning: argument name 'p_on1' in comment does not match parameter name 'p_one'
+// CHECK-NOTES: [[@LINE-2]]:26: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-39]]:28: note: 'p_one' declared here
+// CHECK-NOTES: [[@LINE-35]]:3: note: actual callee ('gmock_Method2') is declared here
+// CHECK-NOTES: [[@LINE-53]]:36: note: expanded from macro 'MOCK_CONST_METHOD2'
+// CHECK-NOTES: [[@LINE-57]]:7: note: expanded from macro 'GMOCK_METHOD2_'
+// CHECK-NOTES: note: expanded from here
+// CHECK-NOTES: [[@LINE-8]]:44: warning: argument name 'p_tw2' in comment does not match parameter name 'p_two'
+// CHECK-NOTES: [[@LINE-9]]:44: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-46]]:39: note: 'p_two' declared here
+// CHECK-NOTES: [[@LINE-42]]:3: note: actual callee ('gmock_Method2') is declared here
+// CHECK-NOTES: [[@LINE-60]]:36: note: expanded from macro 'MOCK_CONST_METHOD2'
+// CHECK-NOTES: [[@LINE-64]]:7: note: expanded from macro 'GMOCK_METHOD2_'
+// CHECK-NOTES: note: expanded from here
 // CHECK-FIXES:   EXPECT_CALL(m, Method2(/*p_one=*/PARAM1, /*p_two=*/PARAM2));
 
   MockStandalone m2;
@@ -103,6 +127,9 @@ void test_gmock_expectations() {
 void test_gmock_direct_calls() {
   MockDerived m;
   m.Method(/*param_one=*/1, /*param_tw=*/2);
-// CHECK-MESSAGES: [[@LINE-1]]:29: warning: argument name 'param_tw' in comment does not match parameter name 'param_two'
+// CHECK-NOTES: [[@LINE-1]]:29: warning: argument name 'param_tw' in comment does not match parameter name 'param_two'
+// CHECK-NOTES: [[@LINE-2]]:29: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-63]]:42: note: 'param_two' declared here
+// CHECK-NOTES: [[@LINE-59]]:16: note: actual callee ('Method') is declared here
 // CHECK-FIXES:   m.Method(/*param_one=*/1, /*param_two=*/2);
 }

Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-strict.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-strict.cpp?rev=342458&r1=342457&r2=342458&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-strict.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-strict.cpp Tue Sep 18 03:15:15 2018
@@ -5,15 +5,24 @@ void f(int _with_underscores_);
 void g(int x_);
 void ignores_underscores() {
   f(/*With_Underscores=*/0);
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument name 'With_Underscores' in comment does not match parameter name '_with_underscores_'
+// CHECK-NOTES: [[@LINE-1]]:5: warning: argument name 'With_Underscores' in comment does not match parameter name '_with_underscores_'
+// CHECK-NOTES: [[@LINE-2]]:5: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-6]]:12: note: '_with_underscores_' declared here
 // CHECK-FIXES: f(/*_with_underscores_=*/0);
+
   f(/*with_underscores=*/1);
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument name 'with_underscores' in comment does not match parameter name '_with_underscores_'
+// CHECK-NOTES: [[@LINE-1]]:5: warning: argument name 'with_underscores' in comment does not match parameter name '_with_underscores_'
+// CHECK-NOTES: [[@LINE-2]]:5: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-12]]:12: note: '_with_underscores_' declared here
 // CHECK-FIXES: f(/*_with_underscores_=*/1);
   f(/*_With_Underscores_=*/2);
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument name '_With_Underscores_' in comment does not match parameter name '_with_underscores_'
+// CHECK-NOTES: [[@LINE-1]]:5: warning: argument name '_With_Underscores_' in comment does not match parameter name '_with_underscores_'
+// CHECK-NOTES: [[@LINE-2]]:5: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-17]]:12: note: '_with_underscores_' declared here
 // CHECK-FIXES: f(/*_with_underscores_=*/2);
   g(/*X=*/3);
-// CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument name 'X' in comment does not match parameter name 'x_'
+// CHECK-NOTES: [[@LINE-1]]:5: warning: argument name 'X' in comment does not match parameter name 'x_'
+// CHECK-NOTES: [[@LINE-2]]:5: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-21]]:12: note: 'x_' declared here
 // CHECK-FIXES: g(/*x_=*/3);
 }

Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment.cpp?rev=342458&r1=342457&r2=342458&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment.cpp Tue Sep 18 03:15:15 2018
@@ -7,10 +7,10 @@ void ffff(int xxxx, int yyyy);
 
 void f(int x, int y);
 void g() {
-  // CHECK-MESSAGES: [[@LINE+4]]:5: warning: argument name 'y' in comment does not match parameter name 'x'
-  // CHECK-MESSAGES: :[[@LINE-3]]:12: note: 'x' declared here
-  // CHECK-MESSAGES: [[@LINE+2]]:14: warning: argument name 'z' in comment does not match parameter name 'y'
-  // CHECK-MESSAGES: :[[@LINE-5]]:19: note: 'y' declared here
+  // CHECK-NOTES: [[@LINE+4]]:5: warning: argument name 'y' in comment does not match parameter name 'x'
+  // CHECK-NOTES: [[@LINE-3]]:12: note: 'x' declared here
+  // CHECK-NOTES: [[@LINE+2]]:14: warning: argument name 'z' in comment does not match parameter name 'y'
+  // CHECK-NOTES: [[@LINE-5]]:19: note: 'y' declared here
   f(/*y=*/0, /*z=*/0);
   // CHECK-FIXES: {{^}}  f(/*y=*/0, /*z=*/0);
 
@@ -46,14 +46,17 @@ void variadic2(int zzz, Args&&... args);
 void templates() {
   variadic(/*xxx=*/0, /*yyy=*/1);
   variadic2(/*zzU=*/0, /*xxx=*/1, /*yyy=*/2);
-  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: argument name 'zzU' in comment does not match parameter name 'zzz'
+  // CHECK-NOTES: [[@LINE-1]]:13: warning: argument name 'zzU' in comment does not match parameter name 'zzz'
+  // CHECK-NOTES: [[@LINE-2]]:13: note: FIX-IT applied suggested code changes
+  // CHECK-NOTES: :[[@LINE-7]]:20: note: 'zzz' declared here
   // CHECK-FIXES: variadic2(/*zzz=*/0, /*xxx=*/1, /*yyy=*/2);
 }
 
 #define FALSE 0
 void qqq(bool aaa);
 void f2() { qqq(/*bbb=*/FALSE); }
-// CHECK-MESSAGES: [[@LINE-1]]:17: warning: argument name 'bbb' in comment does not match parameter name 'aaa'
+// CHECK-NOTES: [[@LINE-1]]:17: warning: argument name 'bbb' in comment does not match parameter name 'aaa'
+// CHECK-NOTES: [[@LINE-3]]:15: note: 'aaa' declared here
 // CHECK-FIXES: void f2() { qqq(/*bbb=*/FALSE); }
 
 void f3(bool _with_underscores_);
@@ -64,26 +67,32 @@ void ignores_underscores() {
 namespace ThisEditDistanceAboveThreshold {
 void f4(int xxx);
 void g() { f4(/*xyz=*/0); }
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'xyz' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'xyz' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-3]]:13: note: 'xxx' declared here
 // CHECK-FIXES: void g() { f4(/*xyz=*/0); }
 }
 
 namespace OtherEditDistanceAboveThreshold {
 void f5(int xxx, int yyy);
 void g() { f5(/*Zxx=*/0, 0); }
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-2]]:15: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-4]]:13: note: 'xxx' declared here
 // CHECK-FIXES: void g() { f5(/*xxx=*/0, 0); }
 struct C2 {
   C2(int xxx, int yyy);
 };
 C2 c2(/*Zxx=*/0, 0);
-// CHECK-MESSAGES: [[@LINE-1]]:7: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-1]]:7: warning: argument name 'Zxx' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-2]]:7: note: FIX-IT applied suggested code changes
+// CHECK-NOTES: [[@LINE-5]]:10: note: 'xxx' declared here
 // CHECK-FIXES: C2 c2(/*xxx=*/0, 0);
 }
 
 namespace OtherEditDistanceBelowThreshold {
 void f6(int xxx, int yyy);
 void g() { f6(/*xxy=*/0, 0); }
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: argument name 'xxy' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-1]]:15: warning: argument name 'xxy' in comment does not match parameter name 'xxx'
+// CHECK-NOTES: [[@LINE-3]]:13: note: 'xxx' declared here
 // CHECK-FIXES: void g() { f6(/*xxy=*/0, 0); }
 }




More information about the cfe-commits mailing list