|
1 | | -// RUN: %check_clang_tidy -std=c++98 -check-suffixes=,CXX %s readability-use-concise-preprocessor-directives %t |
2 | | -// RUN: %check_clang_tidy -std=c++11 -check-suffixes=,CXX %s readability-use-concise-preprocessor-directives %t |
3 | | -// RUN: %check_clang_tidy -std=c++14 -check-suffixes=,CXX %s readability-use-concise-preprocessor-directives %t |
4 | | -// RUN: %check_clang_tidy -std=c++17 -check-suffixes=,CXX %s readability-use-concise-preprocessor-directives %t |
5 | | -// RUN: %check_clang_tidy -std=c++20 -check-suffixes=,CXX %s readability-use-concise-preprocessor-directives %t |
| 1 | +// RUN: %check_clang_tidy -std=c++98,c++11,c++14,c++17,c++20 -check-suffixes=,CXX %s readability-use-concise-preprocessor-directives %t |
6 | 2 | // RUN: %check_clang_tidy -std=c++23-or-later -check-suffixes=,23,CXX,CXX23 %s readability-use-concise-preprocessor-directives %t |
7 | 3 |
|
8 | | -// RUN: %check_clang_tidy -std=c99 %s readability-use-concise-preprocessor-directives %t -- -- -x c |
9 | | -// RUN: %check_clang_tidy -std=c11 %s readability-use-concise-preprocessor-directives %t -- -- -x c |
| 4 | +// RUN: %check_clang_tidy -std=c99,c17,c11 %s readability-use-concise-preprocessor-directives %t -- -- -x c |
10 | 5 | // RUN: %check_clang_tidy -std=c23-or-later -check-suffixes=,23 %s readability-use-concise-preprocessor-directives %t -- -- -x c |
11 | 6 |
|
12 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifdef [readability-use-concise-preprocessor-directives] |
| 7 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives] |
13 | 8 | // CHECK-FIXES: #ifdef FOO |
14 | 9 | #if defined(FOO) |
15 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifdef [readability-use-concise-preprocessor-directives] |
| 10 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] |
16 | 11 | // CHECK-FIXES-23: #elifdef BAR |
17 | 12 | #elif defined(BAR) |
18 | 13 | #endif |
19 | 14 |
|
20 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifdef [readability-use-concise-preprocessor-directives] |
| 15 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives] |
21 | 16 | // CHECK-FIXES: #ifdef FOO |
22 | 17 | #if defined FOO |
23 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifdef [readability-use-concise-preprocessor-directives] |
| 18 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] |
24 | 19 | // CHECK-FIXES-23: #elifdef BAR |
25 | 20 | #elif defined BAR |
26 | 21 | #endif |
27 | 22 |
|
28 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifdef [readability-use-concise-preprocessor-directives] |
| 23 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives] |
29 | 24 | // CHECK-FIXES: #ifdef FOO |
30 | 25 | #if (defined(FOO)) |
31 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:4: warning: preprocessor condition can be written more concisely using #elifdef [readability-use-concise-preprocessor-directives] |
| 26 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:4: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] |
32 | 27 | // CHECK-FIXES-23: # elifdef BAR |
33 | 28 | # elif (defined(BAR)) |
34 | 29 | #endif |
35 | 30 |
|
36 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifdef [readability-use-concise-preprocessor-directives] |
| 31 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifdef' [readability-use-concise-preprocessor-directives] |
37 | 32 | // CHECK-FIXES: #ifdef FOO |
38 | 33 | #if (defined FOO) |
39 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:4: warning: preprocessor condition can be written more concisely using #elifdef [readability-use-concise-preprocessor-directives] |
| 34 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:4: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] |
40 | 35 | // CHECK-FIXES-23: # elifdef BAR |
41 | 36 | # elif (defined BAR) |
42 | 37 | #endif |
43 | 38 |
|
44 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 39 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
45 | 40 | // CHECK-FIXES: #ifndef FOO |
46 | 41 | #if !defined(FOO) |
47 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifndef [readability-use-concise-preprocessor-directives] |
| 42 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifndef' [readability-use-concise-preprocessor-directives] |
48 | 43 | // CHECK-FIXES-23: #elifndef BAR |
49 | 44 | #elif !defined(BAR) |
50 | 45 | #endif |
51 | 46 |
|
52 | 47 | #ifdef __cplusplus |
53 | | -// CHECK-MESSAGES-CXX: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 48 | +// CHECK-MESSAGES-CXX: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
54 | 49 | // CHECK-FIXES-CXX: #ifndef FOO |
55 | 50 | #if not defined(FOO) |
56 | | -// CHECK-MESSAGES-CXX23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifndef [readability-use-concise-preprocessor-directives] |
| 51 | +// CHECK-MESSAGES-CXX23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifndef' [readability-use-concise-preprocessor-directives] |
57 | 52 | // CHECK-FIXES-CXX23: #elifndef BAR |
58 | 53 | #elif not defined(BAR) |
59 | 54 | #endif |
60 | 55 | #endif // __cplusplus |
61 | 56 |
|
62 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 57 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
63 | 58 | // CHECK-FIXES: #ifndef FOO |
64 | 59 | #if !defined FOO |
65 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifndef [readability-use-concise-preprocessor-directives] |
| 60 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifndef' [readability-use-concise-preprocessor-directives] |
66 | 61 | // CHECK-FIXES-23: #elifndef BAR |
67 | 62 | #elif !defined BAR |
68 | 63 | #endif |
69 | 64 |
|
70 | 65 | #ifdef __cplusplus |
71 | | -// CHECK-MESSAGES-CXX: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 66 | +// CHECK-MESSAGES-CXX: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
72 | 67 | // CHECK-FIXES-CXX: #ifndef FOO |
73 | 68 | #if not defined FOO |
74 | | -// CHECK-MESSAGES-CXX23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifndef [readability-use-concise-preprocessor-directives] |
| 69 | +// CHECK-MESSAGES-CXX23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifndef' [readability-use-concise-preprocessor-directives] |
75 | 70 | // CHECK-FIXES-CXX23: #elifndef BAR |
76 | 71 | #elif not defined BAR |
77 | 72 | #endif |
78 | 73 | #endif // __cplusplus |
79 | 74 |
|
80 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 75 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
81 | 76 | // CHECK-FIXES: #ifndef FOO |
82 | 77 | #if (!defined(FOO)) |
83 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifndef [readability-use-concise-preprocessor-directives] |
| 78 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifndef' [readability-use-concise-preprocessor-directives] |
84 | 79 | // CHECK-FIXES-23: #elifndef BAR |
85 | 80 | #elif (!defined(BAR)) |
86 | 81 | #endif |
87 | 82 |
|
88 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 83 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
89 | 84 | // CHECK-FIXES: #ifndef FOO |
90 | 85 | #if (!defined FOO) |
91 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifndef [readability-use-concise-preprocessor-directives] |
| 86 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifndef' [readability-use-concise-preprocessor-directives] |
92 | 87 | // CHECK-FIXES-23: #elifndef BAR |
93 | 88 | #elif (!defined BAR) |
94 | 89 | #endif |
95 | 90 |
|
96 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 91 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
97 | 92 | // CHECK-FIXES: #ifndef FOO |
98 | 93 | #if !(defined(FOO)) |
99 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifndef [readability-use-concise-preprocessor-directives] |
| 94 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifndef' [readability-use-concise-preprocessor-directives] |
100 | 95 | // CHECK-FIXES-23: #elifndef BAR |
101 | 96 | #elif !(defined(BAR)) |
102 | 97 | #endif |
103 | 98 |
|
104 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 99 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
105 | 100 | // CHECK-FIXES: #ifndef FOO |
106 | 101 | #if !(defined FOO) |
107 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifndef [readability-use-concise-preprocessor-directives] |
| 102 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifndef' [readability-use-concise-preprocessor-directives] |
108 | 103 | // CHECK-FIXES-23: #elifndef BAR |
109 | 104 | #elif !(defined BAR) |
110 | 105 | #endif |
|
113 | 108 | // handling them doesn't really add any complexity to the implementation. |
114 | 109 | // Test them for good measure. |
115 | 110 |
|
116 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 111 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
117 | 112 | // CHECK-FIXES: #ifndef FOO |
118 | 113 | #if !((!!(defined(FOO)))) |
119 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifdef [readability-use-concise-preprocessor-directives] |
| 114 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] |
120 | 115 | // CHECK-FIXES-23: #elifdef BAR |
121 | 116 | #elif ((!(!(defined(BAR))))) |
122 | 117 | #endif |
123 | 118 |
|
124 | | -// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #ifndef [readability-use-concise-preprocessor-directives] |
| 119 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
125 | 120 | // CHECK-FIXES: #ifndef FOO |
126 | 121 | #if !((!!(defined FOO))) |
127 | | -// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using #elifdef [readability-use-concise-preprocessor-directives] |
| 122 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] |
128 | 123 | // CHECK-FIXES-23: #elifdef BAR |
129 | 124 | #elif ((!(!(defined BAR)))) |
130 | 125 | #endif |
131 | 126 |
|
| 127 | +// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#ifndef' [readability-use-concise-preprocessor-directives] |
| 128 | +// CHECK-FIXES: #ifndef FOO |
| 129 | +#if !( (!! ( defined FOO )) ) |
| 130 | +// CHECK-MESSAGES-23: :[[@LINE+2]]:2: warning: preprocessor condition can be written more concisely using '#elifdef' [readability-use-concise-preprocessor-directives] |
| 131 | +// CHECK-FIXES-23: #elifdef BAR |
| 132 | +#elif ( ( !(!( defined BAR) ) )) |
| 133 | +#endif |
| 134 | + |
132 | 135 | #if FOO |
133 | 136 | #elif BAR |
134 | 137 | #endif |
135 | 138 |
|
136 | 139 | #if defined(FOO) && defined(BAR) |
137 | 140 | #elif defined(FOO) && defined(BAR) |
138 | 141 | #endif |
| 142 | + |
| 143 | +#if defined FOO && BAR |
| 144 | +#endif |
0 commit comments