[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 6 05:43:19 PDT 2017
hokein created this revision.
Herald added a subscriber: mgorny.
The "performance-inefficient-vector-operation" check finds vector oprations in
for-loop statements which may cause multiple memory reallocations.
This is the first version, only detects typical for-loop:
std::vector<int> v;
for (int i = 0; i < n; ++i) {
v.push_back(i);
}
// or
for (int i = 0; i < v2.size(); ++i) {
v.push_back(v2[i]);
}
We can extend it to handle more cases like for-range loop in the future.
https://reviews.llvm.org/D31757
Files:
clang-tidy/performance/CMakeLists.txt
clang-tidy/performance/InefficientVectorOperationCheck.cpp
clang-tidy/performance/InefficientVectorOperationCheck.h
clang-tidy/performance/PerformanceTidyModule.cpp
docs/clang-tidy/checks/list.rst
docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
test/clang-tidy/performance-inefficient-vector-operation.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31757.94355.patch
Type: text/x-patch
Size: 11518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170406/4aea90a2/attachment.bin>
More information about the cfe-commits
mailing list