summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Toth <jonas.toth@gmail.com>2018-09-25 18:15:52 +0000
committerJonas Toth <jonas.toth@gmail.com>2018-09-25 18:15:52 +0000
commit0ec3185db907b452e394c20c83612e2f77b4b3d8 (patch)
tree223c93d2f897f1c51e70962e348d0f57218fe94f
parentd1bd01c3183f537cbf63a71b8303a656b4c6cb65 (diff)
downloadbcm5719-llvm-0ec3185db907b452e394c20c83612e2f77b4b3d8.tar.gz
bcm5719-llvm-0ec3185db907b452e394c20c83612e2f77b4b3d8.zip
[clang-tidy] use CHECK-NOTES in tests for bugprone-macro-repeated-side-effects
Reviewers: alexfh, aaron.ballman, hokein Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D52230 llvm-svn: 343001
-rw-r--r--clang-tools-extra/test/clang-tidy/bugprone-macro-repeated-side-effects.c57
1 files changed, 38 insertions, 19 deletions
diff --git a/clang-tools-extra/test/clang-tidy/bugprone-macro-repeated-side-effects.c b/clang-tools-extra/test/clang-tidy/bugprone-macro-repeated-side-effects.c
index bcea47a4c11..995d872dce7 100644
--- a/clang-tools-extra/test/clang-tidy/bugprone-macro-repeated-side-effects.c
+++ b/clang-tools-extra/test/clang-tidy/bugprone-macro-repeated-side-effects.c
@@ -3,21 +3,29 @@
#define badA(x,y) ((x)+((x)+(y))+(y))
void bad(int ret, int a, int b) {
ret = badA(a++, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x' are repeated in macro expansion [bugprone-macro-repeated-side-effects]
+ // CHECK-NOTES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x' are repeated in macro expansion [bugprone-macro-repeated-side-effects]
+ // CHECK-NOTES: :[[@LINE-4]]:9: note: macro 'badA' defined here
ret = badA(++a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-7]]:9: note: macro 'badA' defined here
ret = badA(a--, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-10]]:9: note: macro 'badA' defined here
ret = badA(--a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-1]]:14: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-13]]:9: note: macro 'badA' defined here
ret = badA(a, b++);
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro argument 'y'
+ // CHECK-NOTES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro argument 'y'
+ // CHECK-NOTES: :[[@LINE-16]]:9: note: macro 'badA' defined here
ret = badA(a, ++b);
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro argument 'y'
+ // CHECK-NOTES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro argument 'y'
+ // CHECK-NOTES: :[[@LINE-19]]:9: note: macro 'badA' defined here
ret = badA(a, b--);
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro argument 'y'
+ // CHECK-NOTES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro argument 'y'
+ // CHECK-NOTES: :[[@LINE-22]]:9: note: macro 'badA' defined here
ret = badA(a, --b);
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro argument 'y'
+ // CHECK-NOTES: :[[@LINE-1]]:17: warning: side effects in the 2nd macro argument 'y'
+ // CHECK-NOTES: :[[@LINE-25]]:9: note: macro 'badA' defined here
}
@@ -25,15 +33,20 @@ void bad(int ret, int a, int b) {
#define LIMIT(X,A,B) ((X) < (A) ? (A) : ((X) > (B) ? (B) : (X))) // two ?:
void question(int x) {
MIN(x++, 12);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: side effects in the 1st macro argument 'A'
+ // CHECK-NOTES: :[[@LINE-1]]:7: warning: side effects in the 1st macro argument 'A'
+ // CHECK-NOTES: :[[@LINE-5]]:9: note: macro 'MIN' defined here
MIN(34, x++);
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: side effects in the 2nd macro argument 'B'
+ // CHECK-NOTES: :[[@LINE-1]]:11: warning: side effects in the 2nd macro argument 'B'
+ // CHECK-NOTES: :[[@LINE-8]]:9: note: macro 'MIN' defined here
LIMIT(x++, 0, 100);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: side effects in the 1st macro argument 'X'
+ // CHECK-NOTES: :[[@LINE-1]]:9: warning: side effects in the 1st macro argument 'X'
+ // CHECK-NOTES: :[[@LINE-10]]:9: note: macro 'LIMIT' defined here
LIMIT(20, x++, 100);
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: side effects in the 2nd macro argument 'A'
+ // CHECK-NOTES: :[[@LINE-1]]:13: warning: side effects in the 2nd macro argument 'A'
+ // CHECK-NOTES: :[[@LINE-13]]:9: note: macro 'LIMIT' defined here
LIMIT(20, 0, x++);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: side effects in the 3rd macro argument 'B'
+ // CHECK-NOTES: :[[@LINE-1]]:16: warning: side effects in the 3rd macro argument 'B'
+ // CHECK-NOTES: :[[@LINE-16]]:9: note: macro 'LIMIT' defined here
}
// False positive: Repeated side effects is intentional.
@@ -41,7 +54,8 @@ void question(int x) {
#define UNROLL(A) {A A}
void fp1(int i) {
UNROLL({ i++; });
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: side effects in the 1st macro argument 'A'
+ // CHECK-NOTES: :[[@LINE-1]]:10: warning: side effects in the 1st macro argument 'A'
+ // CHECK-NOTES: :[[@LINE-4]]:9: note: macro 'UNROLL' defined here
}
// Do not produce a false positive on a strchr() macro. Explanation; Currently the '?'
@@ -66,11 +80,14 @@ void pass(char* pstr, char ch) {
(v) + (v) + (x) + (x) + (y) + (y) + (z) + (z))
void large(int a) {
largeA(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, a++, 0, 0, 0, 0, 0, 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:64: warning: side effects in the 19th macro argument 's'
+ // CHECK-NOTES: :[[@LINE-1]]:64: warning: side effects in the 19th macro argument 's'
+ // CHECK-NOTES: :[[@LINE-8]]:9: note: macro 'largeA' defined here
largeA(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, a++, 0, 0, 0, 0, 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:67: warning: side effects in the 20th macro argument 't'
+ // CHECK-NOTES: :[[@LINE-1]]:67: warning: side effects in the 20th macro argument 't'
+ // CHECK-NOTES: :[[@LINE-11]]:9: note: macro 'largeA' defined here
largeA(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, a++, 0, 0, 0, 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:70: warning: side effects in the 21st macro argument 'u'
+ // CHECK-NOTES: :[[@LINE-1]]:70: warning: side effects in the 21st macro argument 'u'
+ // CHECK-NOTES: :[[@LINE-14]]:9: note: macro 'largeA' defined here
}
// Passing macro argument as argument to __builtin_constant_p and macros.
@@ -81,13 +98,15 @@ void large(int a) {
#define macrogood(x) (builtingood1(x) + (x))
void builtins(int ret, int a) {
ret += builtinbad(a++);
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-1]]:21: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-8]]:9: note: macro 'builtinbad' defined here
ret += builtingood1(a++);
ret += builtingood2(a++);
ret += macrobad(a++);
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-1]]:19: warning: side effects in the 1st macro argument 'x'
+ // CHECK-NOTES: :[[@LINE-12]]:9: note: macro 'macrobad' defined here
ret += macrogood(a++);
}
OpenPOWER on IntegriCloud