1*52296f5eSPiotr Zegar // RUN: %check_clang_tidy %s readability-avoid-unconditional-preprocessor-if %t
2*52296f5eSPiotr Zegar 
3*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'false', consider removing both the condition and its contents [readability-avoid-unconditional-preprocessor-if]
4*52296f5eSPiotr Zegar #if 0
5*52296f5eSPiotr Zegar // some code
6*52296f5eSPiotr Zegar #endif
7*52296f5eSPiotr Zegar 
8*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'true', consider removing condition but leaving its contents [readability-avoid-unconditional-preprocessor-if]
9*52296f5eSPiotr Zegar #if 1
10*52296f5eSPiotr Zegar // some code
11*52296f5eSPiotr Zegar #endif
12*52296f5eSPiotr Zegar 
13*52296f5eSPiotr Zegar #if test
14*52296f5eSPiotr Zegar 
15*52296f5eSPiotr Zegar #endif
16*52296f5eSPiotr Zegar 
17*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'true', consider removing condition but leaving its contents [readability-avoid-unconditional-preprocessor-if]
18*52296f5eSPiotr Zegar #if 10>5
19*52296f5eSPiotr Zegar 
20*52296f5eSPiotr Zegar #endif
21*52296f5eSPiotr Zegar 
22*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'false', consider removing both the condition and its contents [readability-avoid-unconditional-preprocessor-if]
23*52296f5eSPiotr Zegar #if 10<5
24*52296f5eSPiotr Zegar 
25*52296f5eSPiotr Zegar #endif
26*52296f5eSPiotr Zegar 
27*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'true', consider removing condition but leaving its contents [readability-avoid-unconditional-preprocessor-if]
28*52296f5eSPiotr Zegar #if 10 > 5
29*52296f5eSPiotr Zegar // some code
30*52296f5eSPiotr Zegar #endif
31*52296f5eSPiotr Zegar 
32*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'false', consider removing both the condition and its contents [readability-avoid-unconditional-preprocessor-if]
33*52296f5eSPiotr Zegar #if 10 < 5
34*52296f5eSPiotr Zegar // some code
35*52296f5eSPiotr Zegar #endif
36*52296f5eSPiotr Zegar 
37*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'false', consider removing both the condition and its contents [readability-avoid-unconditional-preprocessor-if]
38*52296f5eSPiotr Zegar #if !(10 > \
39*52296f5eSPiotr Zegar         5)
40*52296f5eSPiotr Zegar // some code
41*52296f5eSPiotr Zegar #endif
42*52296f5eSPiotr Zegar 
43*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'true', consider removing condition but leaving its contents [readability-avoid-unconditional-preprocessor-if]
44*52296f5eSPiotr Zegar #if !(10 < \
45*52296f5eSPiotr Zegar         5)
46*52296f5eSPiotr Zegar // some code
47*52296f5eSPiotr Zegar #endif
48*52296f5eSPiotr Zegar 
49*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'true', consider removing condition but leaving its contents [readability-avoid-unconditional-preprocessor-if]
50*52296f5eSPiotr Zegar #if true
51*52296f5eSPiotr Zegar // some code
52*52296f5eSPiotr Zegar #endif
53*52296f5eSPiotr Zegar 
54*52296f5eSPiotr Zegar // CHECK-MESSAGES: :[[@LINE+1]]:2: warning: preprocessor condition is always 'false', consider removing both the condition and its contents [readability-avoid-unconditional-preprocessor-if]
55*52296f5eSPiotr Zegar #if false
56*52296f5eSPiotr Zegar // some code
57*52296f5eSPiotr Zegar #endif
58*52296f5eSPiotr Zegar 
59*52296f5eSPiotr Zegar #define MACRO
60*52296f5eSPiotr Zegar #ifdef MACRO
61*52296f5eSPiotr Zegar // some code
62*52296f5eSPiotr Zegar #endif
63*52296f5eSPiotr Zegar 
64*52296f5eSPiotr Zegar #if !SOMETHING
65*52296f5eSPiotr Zegar #endif
66*52296f5eSPiotr Zegar 
67*52296f5eSPiotr Zegar #if !( \
68*52296f5eSPiotr Zegar      defined MACRO)
69*52296f5eSPiotr Zegar // some code
70*52296f5eSPiotr Zegar #endif
71*52296f5eSPiotr Zegar 
72*52296f5eSPiotr Zegar 
73*52296f5eSPiotr Zegar #if __has_include(<string_view>)
74*52296f5eSPiotr Zegar // some code
75*52296f5eSPiotr Zegar #endif
76*52296f5eSPiotr Zegar 
77*52296f5eSPiotr Zegar #if __has_include(<string_view_not_exist>)
78*52296f5eSPiotr Zegar // some code
79*52296f5eSPiotr Zegar #endif
80*52296f5eSPiotr Zegar 
81*52296f5eSPiotr Zegar #define DDD 17
82*52296f5eSPiotr Zegar #define EEE 18
83*52296f5eSPiotr Zegar 
84*52296f5eSPiotr Zegar #if 10 > DDD
85*52296f5eSPiotr Zegar // some code
86*52296f5eSPiotr Zegar #endif
87*52296f5eSPiotr Zegar 
88*52296f5eSPiotr Zegar #if 10 < DDD
89*52296f5eSPiotr Zegar // some code
90*52296f5eSPiotr Zegar #endif
91*52296f5eSPiotr Zegar 
92*52296f5eSPiotr Zegar #if EEE > DDD
93*52296f5eSPiotr Zegar // some code
94*52296f5eSPiotr Zegar #endif
95