Issue 171130
Summary [clang-tidy] Add IgnoreMacros option to 'bugprone-chained-comparison'
Labels enhancement, clang-tidy
Assignees
Reporter vbvictor
    Repro: https://godbolt.org/z/aGK1hMh8e.
Maybe we need global `IgnoreMacros` for all checks?.. Adding these options one by one seems unproductive.

Real-world case with Catch2 test framework where user-code clearly has no "chained comparison":
```cpp
parser.cpp:29:5: warning: chained comparison 'v0 <= v1 == v2' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions [bugprone-chained-comparison]
   29 |     REQUIRE(regex_str == t.sms_regex);
      | ^
build/_deps/catch2-src/src/catch2/../catch2/catch_test_macros.hpp:125:26: note: expanded from macro 'REQUIRE'
  125 |   #define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__  )
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build/_deps/catch2-src/src/catch2/../catch2/internal/catch_test_macro_impl.hpp:52:47: note: expanded from macro 'INTERNAL_CATCH_TEST'
   52 | catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parser.cpp:29:5: note: operand 'v0' is here
   29 |     REQUIRE(regex_str == t.sms_regex);
      | ^
build/_deps/catch2-src/src/catch2/../catch2/catch_test_macros.hpp:125:26: note: expanded from macro 'REQUIRE'
  125 |   #define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__  )
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
build/_deps/catch2-src/src/catch2/../catch2/internal/catch_test_macro_impl.hpp:52:47: note: expanded from macro 'INTERNAL_CATCH_TEST'
   52 | catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
 | ^~~~~~~~~~~~~~~~~~~
parser.cpp:29:13: note: operand 'v1' is here
   29 | REQUIRE(regex_str == t.sms_regex);
      |             ^
parser.cpp:29:26: note: operand 'v2' is here
   29 |     REQUIRE(regex_str == t.sms_regex);
 | ^
build/_deps/catch2-src/src/catch2/../catch2/catch_test_macros.hpp:125:92: note: expanded from macro 'REQUIRE'
  125 |   #define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__  )
      | ^~~~~~~~~~~
build/_deps/catch2-src/src/catch2/../catch2/internal/catch_test_macro_impl.hpp:52:70: note: expanded from macro 'INTERNAL_CATCH_TEST'
   52 | catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to