aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-tidy/checkers/readability
diff options
context:
space:
mode:
authorDanny Mösch <danny.moesch@icloud.com>2024-01-14 01:14:38 +0100
committerGitHub <noreply@github.com>2024-01-14 01:14:38 +0100
commit5295ca1a8e5844b44d6b4140ea46405301e9c63f (patch)
tree2bcfeae78ac7ebea983bb6abc5291415bee5e59b /clang-tools-extra/test/clang-tidy/checkers/readability
parent21b2f305c90c99066ce251e7c63b411bf1a9e765 (diff)
downloadllvm-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.cpp20
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);
+}