This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Improve bugprone-branch-clone with support for fallthrough attribute
ClosedPublic

Authored by PiotrZSL on Apr 9 2023, 12:03 PM.

Details

Summary

Ignore duplicated switch cases with [[fallthrough]] attribute to reduce false positives.

Fixes: #47588

Diff Detail

Event Timeline

PiotrZSL created this revision.Apr 9 2023, 12:03 PM
Herald added a project: Restricted Project. · View Herald Transcript
PiotrZSL requested review of this revision.Apr 9 2023, 12:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2023, 12:03 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
PiotrZSL updated this revision to Diff 524419.May 22 2023, 12:03 PM

Rebase, Ping

Mostly LGTM, I suggested two cosmetic changes.

clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
55

Bikeshedding: these comments are very useful, but put them after the return statements. The (meaningful content) / (number of lines) ratio is already abysmal in visitor classes like this, let's try to avoid what we can.

84

If I understand it correctly, Class::classof(Pointer) is an implementation detail of the more flexible and slightly magical isa<Class>(Obj) utility. The clang-tidy codebase contains lots of isa<> and only a single direct reference to classof() so I'd suggest using isa<> here for the sake of consistency.

PiotrZSL updated this revision to Diff 524769.May 23 2023, 9:40 AM
PiotrZSL marked 2 inline comments as done.

Correct review comments

This revision is now accepted and ready to land.May 23 2023, 10:46 AM