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