HomePhabricator

Fix loop-convert for trivially copyable types.

Description

Fix loop-convert for trivially copyable types.

Previously, we would rewrite:
void f(const vector<int> &v) {

for (size_t i = 0; i < v.size(); ++i) {

to

for (const auto &elem : v) {

Now we rewrite it to:

for (auto elem : v) {

(and similarly for iterator based loops).

Details

Committed
klimekSep 23 2015, 3:28 PM
Parents
rL248437: ARM: fix folding stack adjustment (again again again...)
Branches
Unknown
Tags
Unknown

Event Timeline

alexfh added inline comments.Sep 23 2015, 3:48 PM
/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
604

Maybe auto ValueType = DerefType->getNonReferenceType();?

klimek added a subscriber: klimek.Sep 23 2015, 5:17 PM

Done. Please send post-review comments via the cfe-commits threads in the
future, so they are visible to the list :D

Test test test.

Let's see how adding subscribers from the comments form in Diffusion works.

/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
621

Testtesttest

Test-test-test.

/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
501

Test2.

/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
669

Test3

alexfh added inline comments.Sep 24 2015, 4:25 AM
/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
509

test5

573

test6

The biggest problem is that those comments don't go on the cfe-commmits
thread that gets auto-triggered by commits, and we really want to not add
new threads.