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 = cxxR
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
cfe-commits@lists.llvm.o
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
hokein added a comment.
@alexfh, I'm submitting the patch now. If you have following comments, I'm
happy to address them afterwards.
Repository:
rL LLVM
https://reviews.llvm.org/D31757
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300534: [clang-tidy] Add a clang-tidy check for possible
inefficient vector operations (authored by hokein).
Changed prior to commit:
https://reviews.llvm.org/D31757?vs=95338&id=95534#toc
Repository:
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
http://lists.llvm.org/cgi-bin/mailman
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
clang-tidy/perfo
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
clang-tidy/performance/In
aaron.ballman added inline comments.
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:95-96
+const MatchFinder::MatchResult &Result) {
+ 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("<"),
+ hasLHS(RefersToLoo
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
clang-tidy/perform
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
clang-tidy/perform
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
+ .b
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
+ .b
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 VectorDefaultCons
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
clang-tidy/performa
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 this
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
clang-tid
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
clang-tid
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 (int
28 matches
Mail list logo