This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Match derived types in in modernize-loop-convert
ClosedPublic

Authored by ccotter on Dec 19 2022, 7:30 AM.

Details

Summary

This patch allows clang-tidy to replace traditional for-loops where the
container type inherits its begin/end methods from a base class.

Test plan: Added unit test cases that confirm the tool replaces the new
pattern.

Diff Detail

Event Timeline

ccotter created this revision.Dec 19 2022, 7:30 AM
Herald added a project: Restricted Project. · View Herald Transcript
ccotter requested review of this revision.Dec 19 2022, 7:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 19 2022, 7:30 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

@njames93 would you mind taking a look?

ccotter retitled this revision from Match derived types in in modernize-loop-convert to [clang-tidy] Match derived types in in modernize-loop-convert.Dec 29 2022, 7:44 AM
ccotter updated this revision to Diff 485637.Dec 29 2022, 12:39 PM

Add release note

carlosgalvezp added inline comments.Jan 5 2023, 8:42 AM
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
258

Replace tabs with spaces

clang-tools-extra/docs/ReleaseNotes.rst
207 ↗(On Diff #485637)

Copy-paste typo?

ccotter updated this revision to Diff 486716.Jan 5 2023, 5:11 PM
  • Match derived types in in modernize-loop-convert
  • fix typo
ccotter marked 2 inline comments as done.Jan 5 2023, 5:15 PM
ccotter added inline comments.
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
258

Ah, I think this was before I figured out arc diff and was copy/pasting diff files around :/

Thanks for catching this.

ccotter marked an inline comment as done.Jan 5 2023, 5:26 PM
ccotter added inline comments.
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
258

just to confirm, how did you notice the tabs? I couldnt find them when I downloaded the phab raw diff for any of the versions in the history. I still see a double right arrow » in the phab diff - is that indicating a tab or something else?

As a sanity check, I ran ./clang/tools/clang-format/git-clang-format --binary build/bin/clang-format from the root of my project and the tool did not produce any changes with the latest version of the changes I submitted.

carlosgalvezp accepted this revision.Jan 6 2023, 2:26 AM

LGTM, let's give @njames93 a few days in case he has some comments.

clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
258

You are right, it must be a bug in Phabricator!

This revision is now accepted and ready to land.Jan 6 2023, 2:26 AM

Hi! I'm finding merge conflicts when rebasing the patch on latest trunk, would you mind uploading a rebased version? Thanks!

Rebased! Sorry for the multiple diffs on this phab - I'm still getting the hang of arc diff.