alexfh added a comment.
Awesome, thanks! A few late comments inline.
Comment at:
clang-tools-extra/trunk/clang-tidy/performance/InefficientVectorOperationCheck.cpp:56
+void InefficientVectorOperationCheck::registerMatchers(MatchFinder *Finder) {
+ const auto VectorDecl =
hokein added a comment.
@chapuni, thanks for the workaround. It makes sense to make it work for
targeting msvc. Will fix it in a follow-up.
Repository:
rL LLVM
https://reviews.llvm.org/D31757
___
cfe-commits mailing list
chapuni added a comment.
Does it work for targeting msvc?
See also;
http://bb.pgr.jp/builders/test-clang-tools-msc-x64-on-i686-linux-RA/builds/1043
Appeased in r300545. Would it be happier if it worked with "-target
x86_64-win32"?
Repository:
rL LLVM
https://reviews.llvm.org/D31757
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM!
https://reviews.llvm.org/D31757
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
hokein updated this revision to Diff 95338.
hokein marked 2 inline comments as done.
hokein added a comment.
Address remaining comments.
https://reviews.llvm.org/D31757
Files:
clang-tidy/performance/CMakeLists.txt
clang-tidy/performance/InefficientVectorOperationCheck.cpp
aaron.ballman added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:109-111
+ auto AllVectorVarRefs = utils::decl_ref_expr::allDeclRefExprs(
+ *VectorVarDecl, *LoopParent, *Result.Context);
+ for (const auto *Ref : AllVectorVarRefs)
hokein added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:109-111
+ auto AllVectorVarRefs = utils::decl_ref_expr::allDeclRefExprs(
+ *VectorVarDecl, *LoopParent, *Result.Context);
+ for (const auto *Ref : AllVectorVarRefs) {
hokein updated this revision to Diff 95269.
hokein marked an inline comment as done.
hokein added a comment.
Explicit the type.
https://reviews.llvm.org/D31757
Files:
clang-tidy/performance/CMakeLists.txt
clang-tidy/performance/InefficientVectorOperationCheck.cpp
aaron.ballman added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:95-96
+const MatchFinder::MatchResult ) {
+ if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
+return;
+
hokein wrote:
>
hokein added a comment.
Thanks for the comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:81
+ hasLoopInit(LoopVarInit),
+ hasCondition(binaryOperator(hasOperatorName("<"),
+
hokein updated this revision to Diff 95174.
hokein marked 11 inline comments as done.
hokein added a comment.
Address review comments.
https://reviews.llvm.org/D31757
Files:
clang-tidy/performance/CMakeLists.txt
clang-tidy/performance/InefficientVectorOperationCheck.cpp
aaron.ballman added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:81
+ hasLoopInit(LoopVarInit),
+ hasCondition(binaryOperator(hasOperatorName("<"),
+ hasLHS(RefersToLoopVar),
hokein marked an inline comment as done.
hokein added a comment.
friendly ping @alexfh.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+ hasParent(compoundStmt(unless(has(ReserveCall)),
+
hokein updated this revision to Diff 94969.
hokein added a comment.
Improve the way of detecting pre-allocation usage before the loop.
https://reviews.llvm.org/D31757
Files:
clang-tidy/performance/CMakeLists.txt
clang-tidy/performance/InefficientVectorOperationCheck.cpp
aaron.ballman added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+ hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+
hokein added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+ hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+
aaron.ballman added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+ hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+
hokein added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+ hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+
aaron.ballman added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+ hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+
hokein added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:22
+void InefficientVectorOperationCheck::registerMatchers(MatchFinder *Finder) {
+ const auto VectorDecl = cxxRecordDecl(hasName("std::vector"));
+ const auto
hokein updated this revision to Diff 94734.
hokein marked 7 inline comments as done.
hokein added a comment.
Address review comments.
https://reviews.llvm.org/D31757
Files:
clang-tidy/performance/CMakeLists.txt
clang-tidy/performance/InefficientVectorOperationCheck.cpp
hokein added a comment.
In https://reviews.llvm.org/D31757#720351, @Eugene.Zelenko wrote:
> Isn't such analysis is path-sensitive and should be implemented in Static
> Analyzer?
This check is more like a flow-sensitive analysis IMO, which can be supported
by clang-tidy.
> Please mention
hokein updated this revision to Diff 94498.
hokein marked an inline comment as done.
hokein added a comment.
Mention the check in Release note.
https://reviews.llvm.org/D31757
Files:
clang-tidy/performance/CMakeLists.txt
clang-tidy/performance/InefficientVectorOperationCheck.cpp
Eugene.Zelenko added a comment.
Isn't such analysis is path-sensitive and should be implemented in Static
Analyzer?
Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).
Comment at:
docs/clang-tidy/checks/performance-inefficient-vector-operation.rst:6
hokein updated this revision to Diff 94356.
hokein added a comment.
Fix a small nit.
https://reviews.llvm.org/D31757
Files:
clang-tidy/performance/CMakeLists.txt
clang-tidy/performance/InefficientVectorOperationCheck.cpp
clang-tidy/performance/InefficientVectorOperationCheck.h
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 v;
for
26 matches
Mail list logo