[PATCH] D113201: [clang-tidy] Fix a crash in modernize-loop-convert around conversion operators

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 4 09:56:30 PDT 2021


Szelethus created this revision.
Szelethus added reviewers: aaron.ballman, alexfh, steakhal, whisperity.
Szelethus added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, martong, gamesh411, dkrupp, rnkovacs, xazax.hun.
Szelethus requested review of this revision.
Herald added a subscriber: cfe-commits.

When an iterator is initialized with a conversion operator (e.g. `for (const_iterator it = non_const_container.begin(); ...)`, `getContainerFromBeginEndCall()` failed with an assert. It attempts to retrieve the name of the initializer expression, which in the case of a conversion operator doesn't exist.

I fixed this by making `digThroughConstructors` dig through conversion operators as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113201

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-basic.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113201.384789.patch
Type: text/x-patch
Size: 5444 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211104/f4803dd6/attachment.bin>


More information about the cfe-commits mailing list