brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · d1df79e Raw
31 lines · cpp
1// RUN: %check_clang_tidy -check-suffixes=,MACROS %s readability-simplify-boolean-expr %t2 3// Ignore expressions in macros.4// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t \5// RUN:     -- -config="{CheckOptions: {readability-simplify-boolean-expr.IgnoreMacros: true}}" \6// RUN:     --7 8#define NEGATE(expr) !(expr)9#define NOT_AND_NOT(a, b) (!a && !b)10 11bool without_macro(bool a, bool b) {12    return !(!a && b);13    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: boolean expression can be simplified by DeMorgan's theorem14    // CHECK-FIXES: return a || !b;15}16 17void macro(bool a, bool b) {18    NEGATE(!a && b);19    // CHECK-MESSAGES-MACROS: :[[@LINE-1]]:5: warning: boolean expression can be simplified by DeMorgan's theorem20    // CHECK-FIXES: NEGATE(!a && b);21    !NOT_AND_NOT(a, b);22    // CHECK-MESSAGES-MACROS: :[[@LINE-1]]:5: warning: boolean expression can be simplified by DeMorgan's theorem23    // CHECK-FIXES: !NOT_AND_NOT(a, b);24    !(NEGATE(a) && b);25    // CHECK-MESSAGES-MACROS: :[[@LINE-1]]:5: warning: boolean expression can be simplified by DeMorgan's theorem26    // CHECK-FIXES: !(NEGATE(a) && b);27    !(a && NEGATE(b));28    // CHECK-MESSAGES-MACROS: :[[@LINE-1]]:5: warning: boolean expression can be simplified by DeMorgan's theorem29    // CHECK-FIXES: !(a && NEGATE(b));30}31