[all-commits] [llvm/llvm-project] 29a8d4: [clang-tidy] Fix a crash in modernize-loop-convert...
Kristóf Umann via All-commits
all-commits at lists.llvm.org
Mon Nov 15 04:12:11 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 29a8d45c5a239c9fa6b8634a9de3d655064816d1
https://github.com/llvm/llvm-project/commit/29a8d45c5a239c9fa6b8634a9de3d655064816d1
Author: Kristóf Umann <dkszelethus at gmail.com>
Date: 2021-11-15 (Mon, 15 Nov 2021)
Changed paths:
M clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
M clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
M clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
M clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-loop-convert/structures.h
M clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-basic.cpp
Log Message:
-----------
[clang-tidy] Fix a crash in modernize-loop-convert around conversion operators
modernize-loop-convert checks and fixes when a loop that iterates over the
elements of a container can be rewritten from a for(...; ...; ...) style into
the "new" C++11 for-range format. For that, it needs to parse the elements of
that loop, like its init-statement, such as ItType it = cont.begin().
modernize-loop-convert checks whether the loop variable is initialized by a
begin() member function.
When an iterator is initialized with a conversion operator (e.g. for
(const_iterator it = non_const_container.begin(); ...), attempts to retrieve the
name of the initializer expression resulted in an assert, as conversion
operators don't have a valid IdentifierInfo.
I fixed this by making digThroughConstructors dig through conversion operators
as well.
Differential Revision: https://reviews.llvm.org/D113201
More information about the All-commits
mailing list