Page MenuHomePhabricator

[clang-tidy] Add bugprone-chained-comparison check
Needs ReviewPublic

Authored by PiotrZSL on Mon, Feb 20, 1:19 PM.

Details

Summary

Check that flags chained comparison expressions,
such as a < b < c or a == b == c, which may have
unintended behavior due to implicit operator
associativity.

Diff Detail

Event Timeline

PiotrZSL created this revision.Mon, Feb 20, 1:19 PM
Herald added a project: Restricted Project. · View Herald Transcript

Note that looks like there is currently in implementation new warning -Wcomparison-op-parentheses under D142800, that warning currently handle only chained comparison by using BinaryOperator, not by using CXXOperatorCallExpr.
Scope of "-Wcomparison-op-parentheses" and whatever that warning will be delivered in LLVM 17 will determinate future of this check.
This check is feature-complete.

PiotrZSL published this revision for review.Mon, Feb 20, 1:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Feb 20, 1:43 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
PiotrZSL updated this revision to Diff 503312.Wed, Mar 8, 4:12 AM

Ping, Rebase

PiotrZSL updated this revision to Diff 503362.Wed, Mar 8, 7:30 AM

Rebase due to broken baseline