Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-tidy]: readability-simplify-boolean-expr wants to use DeMorgan's theorem on macros despite IgnoreMacros #91487

Closed
nick-potenski opened this issue May 8, 2024 · 1 comment · Fixed by #91757
Assignees

Comments

@nick-potenski
Copy link

clang-tidy produces a readability-simplify-boolean-expr warning to simplify expressions with macros using DeMorgan's theorem despite readability-simplify-boolean-expr.IgnoreMacros being set to true.

Simplified test case:

#define is_a_favorite_number(_i) (_i == 42 || _i == 3 || _i == 1000000)

bool UseNumber(int i) { return i >= 0 && !is_a_favorite_number(i); }

.clang-tidy config:

---
Checks:
    '-*,
    readability-simplify-boolean-expr
    '
CheckOptions:
    - key:      readability-simplify-boolean-expr.IgnoreMacros
      value:    true

Produces the following:

1 warning generated.
test_bool_simplification.cpp:4:42: error: boolean expression can be simplified by DeMorgan's theorem [readability-simplify-boolean-expr,-warnings-as-errors]
    4 | bool UseNumber(int i) { return i >= 0 && !is_a_favorite_number(i); }
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~
@nick-potenski
Copy link
Author

Oops, forgot to mention that I'm using version 18.1.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants