Fix ForRangeCopyCheck not triggering on iterators returning elements by value in...
authorDmitri Gribenko <gribozavr@gmail.com>
Wed, 6 May 2020 06:50:40 +0000 (08:50 +0200)
committerDmitri Gribenko <gribozavr@gmail.com>
Wed, 6 May 2020 07:42:13 +0000 (09:42 +0200)
commit3adaa97f0157e9d274c4d4e69b733db75b963574
treec87225f072e5881cff4c07bfda35a4270a95165d
parentca09dab303f4fd72343be10dbd362b60a5f91c45
Fix ForRangeCopyCheck not triggering on iterators returning elements by value in C++17.

Summary:
The AST is different in C++17 in that there is no MaterializeTemporaryExpr for in the AST for a loop variable that is initialized from an iterator that returns its elements by value.

Account for this by checking that the variable is not initialized by an operator* call that returns a value type.

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79440
clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/performance-for-range-copy.cpp