diff options
author | Miklos Vajna <vmiklos@vmiklos.hu> | 2019-01-11 07:59:47 +0000 |
---|---|---|
committer | Miklos Vajna <vmiklos@vmiklos.hu> | 2019-01-11 07:59:47 +0000 |
commit | 98ef5337c9dfab72ad8f93a83b6429dfd0da168e (patch) | |
tree | ca8a7fb7c972c6b88dcf918f44ff6b2358864325 /clang-tools-extra/test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp | |
parent | 114ad37c1dc805e1dfd694e076257f87f1b705d0 (diff) | |
download | bcm5719-llvm-98ef5337c9dfab72ad8f93a83b6429dfd0da168e.tar.gz bcm5719-llvm-98ef5337c9dfab72ad8f93a83b6429dfd0da168e.zip |
[clang-tidy] new check 'readability-redundant-preprocessor'
Finds potentially redundant preprocessor directives.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D54349
llvm-svn: 350922
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp b/clang-tools-extra/test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp new file mode 100644 index 00000000000..72b608b1c2c --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/readability-redundant-preprocessor-ifdef.cpp @@ -0,0 +1,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 |