diff options
author | Danny Mösch <danny.moesch@icloud.com> | 2024-01-14 01:14:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-14 01:14:38 +0100 |
commit | 5295ca1a8e5844b44d6b4140ea46405301e9c63f (patch) | |
tree | 2bcfeae78ac7ebea983bb6abc5291415bee5e59b /clang-tools-extra/test/clang-tidy/checkers/readability | |
parent | 21b2f305c90c99066ce251e7c63b411bf1a9e765 (diff) | |
download | llvm-5295ca1a8e5844b44d6b4140ea46405301e9c63f.zip llvm-5295ca1a8e5844b44d6b4140ea46405301e9c63f.tar.gz llvm-5295ca1a8e5844b44d6b4140ea46405301e9c63f.tar.bz2 |
[clang-tidy] Add option to ignore macros in `readability-simplify-boolean-expr` check (#78043)
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/readability')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr-macros.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr-macros.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr-macros.cpp new file mode 100644 index 0000000..7d0cfe7 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr-macros.cpp @@ -0,0 +1,20 @@ +// RUN: %check_clang_tidy -check-suffixes=,MACROS %s readability-simplify-boolean-expr %t + +// Ignore expressions in macros. +// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t \ +// RUN: -- -config="{CheckOptions: {readability-simplify-boolean-expr.IgnoreMacros: true}}" \ +// RUN: -- + +#define NEGATE(expr) !(expr) + +bool without_macro(bool a, bool b) { + return !(!a && b); + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: boolean expression can be simplified by DeMorgan's theorem + // CHECK-FIXES: return a || !b; +} + +bool macro(bool a, bool b) { + return NEGATE(!a && b); + // CHECK-MESSAGES-MACROS: :[[@LINE-1]]:12: warning: boolean expression can be simplified by DeMorgan's theorem + // CHECK-FIXES: return NEGATE(!a && b); +} |