brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 5429898 Raw
85 lines · cpp
1// RUN: %check_clang_tidy %s readability-redundant-preprocessor %t -- -- -I %S2 3// Positive testing.4#ifndef FOO5// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifndef; consider removing it [readability-redundant-preprocessor]6#ifndef FOO7// CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifndef was here8void f();9#endif10#endif11 12// Positive testing of inverted condition.13#ifndef FOO14// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor]15#ifdef FOO16// CHECK-NOTES: [[@LINE-3]]:2: note: previous #ifndef was here17void f2();18#endif19#endif20 21// Negative testing.22#include "redundant-preprocessor.h"23 24#ifndef BAR25void g();26#endif27 28#ifndef FOO29#ifndef BAR30void h();31#endif32#endif33 34#ifndef FOO35#ifdef BAR36void i();37#endif38#endif39 40// Positive #if testing.41#define FOO 442 43#if FOO == 444// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]45#if FOO == 446// CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here47void j();48#endif49#endif50 51#if FOO == 3 + 152// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]53#if FOO == 3 + 154// CHECK-NOTES: [[@LINE-3]]:2: note: previous #if was here55void j();56#endif57#endif58 59#if FOO == \60    461// CHECK-NOTES: [[@LINE+1]]:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]62#if FOO == \63    464// CHECK-NOTES: [[@LINE-5]]:2: note: previous #if was here65void j();66#endif67#endif68 69// Negative #if testing.70#define BAR 471 72#if FOO == 473#if BAR == 474void k();75#endif76#endif77 78#if FOO == \79    480#if BAR == \81    582void k();83#endif84#endif85