1 | // RUN: %check_clang_tidy %s readability-redundant-preprocessor %t -- -- -I %S |
2 | |
3 | // Positive testing. |
4 | #ifndef FOO |
5 | // CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifndef; consider removing it [readability-redundant-preprocessor] |
6 | #ifndef FOO |
7 | // CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifndef was here |
8 | void f(); |
9 | #endif |
10 | #endif |
11 | |
12 | // Positive testing of inverted condition. |
13 | #ifndef FOO |
14 | // CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor] |
15 | #ifdef FOO |
16 | // CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifndef was here |
17 | void f2(); |
18 | #endif |
19 | #endif |
20 | |
21 | // Negative testing. |
22 | #include "redundant-preprocessor.h" |
23 | |
24 | #ifndef BAR |
25 | void g(); |
26 | #endif |
27 | |
28 | #ifndef FOO |
29 | #ifndef BAR |
30 | void h(); |
31 | #endif |
32 | #endif |
33 | |
34 | #ifndef FOO |
35 | #ifdef BAR |
36 | void i(); |
37 | #endif |
38 | #endif |
39 | |
40 | // Positive #if testing. |
41 | #define FOO 4 |
42 | |
43 | #if FOO == 4 |
44 | // CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor] |
45 | #if FOO == 4 |
46 | // CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here |
47 | void j(); |
48 | #endif |
49 | #endif |
50 | |
51 | #if FOO == 3 + 1 |
52 | // CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor] |
53 | #if FOO == 3 + 1 |
54 | // CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here |
55 | void j(); |
56 | #endif |
57 | #endif |
58 | |
59 | #if FOO == \ |
60 | 4 |
61 | // CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor] |
62 | #if FOO == \ |
63 | 4 |
64 | // CHECK-NOTES: [[@LINE-5]]:2: note: previous #if was here |
65 | void j(); |
66 | #endif |
67 | #endif |
68 | |
69 | // Negative #if testing. |
70 | #define BAR 4 |
71 | |
72 | #if FOO == 4 |
73 | #if BAR == 4 |
74 | void k(); |
75 | #endif |
76 | #endif |
77 | |
78 | #if FOO == \ |
79 | 4 |
80 | #if BAR == \ |
81 | 5 |
82 | void k(); |
83 | #endif |
84 | #endif |
85 | |