summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-preprocessor-ifdef.cpp
blob: 72b608b1c2c0b9550275cf644309c8b04fd95488 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// RUN: %check_clang_tidy %s readability-redundant-preprocessor %t -- -- -DFOO

// Positive testing.
#ifdef FOO
// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor]
#ifdef FOO
// CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifdef was here
void f();
#endif
#endif

// Positive testing of inverted condition.
#ifdef FOO
// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifndef; consider removing it [readability-redundant-preprocessor]
#ifndef FOO
// CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifdef was here
void f2();
#endif
#endif

// Negative testing.
#ifdef BAR
void g();
#endif

#ifdef FOO
#ifdef BAR
void h();
#endif
#endif

#ifdef FOO
#ifndef BAR
void i();
#endif
#endif
OpenPOWER on IntegriCloud