Run clang-tidy's modernize-loop-convert check |
|
Issue descriptionFrom https://clang.llvm.org/extra/clang-tidy/checks/modernize-loop-convert.html: This check converts for(...; ...; ...) loops to use the new range-based loops in C++11. Three kinds of loops can be converted: Loops over statically allocated arrays. Loops over containers, using iterators. Loops over array-like containers, using operator[] and at(). Examples: Before: for (int i = 0; i < N; ++i) cout << arr[i]; for (vector<int>::iterator it = v.begin(); it != v.end(); ++it) cout << *it; for (int i = 0; i < v.size(); ++i) cout << v[i]; After: for (auto & elem : arr) cout << elem; for (auto & elem : v) cout << elem; for (auto & elem : v) cout << elem; Chrome Specific Notes and Options: - The default options for MaxCopySize (=16 bytes) and MinConfidence (="reasonable") are kept. - Renaming of non-aliased variables is disabled. While this useful in some cases, this can lead to variable names that are grammatically wrong (e.g. "entrie" or "addresse"), or violate the style guide (e.g. "kMyConstantElement"). - In order to be compliant with clang-tidy checks, asterisks are added when iterating over containers of pointers. - Using fundamental types instead of auto is disabled, as this does not respect typedefs and rewrites size_t to unsigned long on a 64-bit machine. The diff against clang-tidy/modernize/LoopConvertCheck.cpp [1] is attached. [1] http://clang.llvm.org/extra/doxygen/LoopConvertCheck_8cpp_source.html
,
Dec 6
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/812de1576d58185d036dc7483646b6b109d87e54 commit 812de1576d58185d036dc7483646b6b109d87e54 Author: jdoerrie <jdoerrie@chromium.org> Date: Thu Dec 06 16:32:02 2018 [clang-tidy] Apply modernize-loop-convert in /base/i18n This change applies clang-tidy's modernize-loop-convert [1] in /base/i18n. Reproduction steps: - run clang-tidy's modernize-loop-convert - run git cl format - manually remove unused constants due to -Wunused-const-variable [1] https://clang.llvm.org/extra/clang-tidy/checks/modernize-loop-convert.html This CL was uploaded by git cl split. R=jshin@chromium.org Bug: 895746 Change-Id: I9b9790b60aaca3f6afb2b4bd1109d800aec5b26a Reviewed-on: https://chromium-review.googlesource.com/c/1282404 Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org> Reviewed-by: Jungshik Shin <jshin@chromium.org> Cr-Commit-Position: refs/heads/master@{#614377} [modify] https://crrev.com/812de1576d58185d036dc7483646b6b109d87e54/base/i18n/break_iterator_unittest.cc [modify] https://crrev.com/812de1576d58185d036dc7483646b6b109d87e54/base/i18n/build_utf8_validator_tables.cc [modify] https://crrev.com/812de1576d58185d036dc7483646b6b109d87e54/base/i18n/file_util_icu_unittest.cc [modify] https://crrev.com/812de1576d58185d036dc7483646b6b109d87e54/base/i18n/number_formatting_unittest.cc [modify] https://crrev.com/812de1576d58185d036dc7483646b6b109d87e54/base/i18n/rtl_unittest.cc [modify] https://crrev.com/812de1576d58185d036dc7483646b6b109d87e54/base/i18n/streaming_utf8_validator_perftest.cc [modify] https://crrev.com/812de1576d58185d036dc7483646b6b109d87e54/base/i18n/streaming_utf8_validator_unittest.cc |
|
►
Sign in to add a comment |
|
Comment 1 by bugdroid1@chromium.org
, Oct 22