This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by PiotrZSL on Feb 20 2023, 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.Feb 20 2023, 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.Feb 20 2023, 1:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2023, 1:43 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
PiotrZSL updated this revision to Diff 503312.Mar 8 2023, 4:12 AM

Ping, Rebase

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

Rebase due to broken baseline

LegalizeAdulthood resigned from this revision.Mar 29 2023, 8:05 AM
PiotrZSL updated this revision to Diff 518342.Apr 30 2023, 11:32 AM

Ping, Rebase

PiotrZSL updated this revision to Diff 551758.Aug 19 2023, 8:14 AM

Rebase + Ping