[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-18 Thread Alexander Kornienko via Phabricator via cfe-commits
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 =

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-18 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-18 Thread NAKAMURA Takumi via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-15 Thread Aaron Ballman via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-14 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-14 Thread Aaron Ballman via Phabricator via cfe-commits
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)

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Haojian Wu via Phabricator via cfe-commits
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) {

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Aaron Ballman via Phabricator via cfe-commits
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: >

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment. Thanks for the comments. Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:81 + hasLoopInit(LoopVarInit), + hasCondition(binaryOperator(hasOperatorName("<"), +

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:81 + hasLoopInit(LoopVarInit), + hasCondition(binaryOperator(hasOperatorName("<"), + hasLHS(RefersToLoopVar),

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-12 Thread Haojian Wu via Phabricator via cfe-commits
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)), +

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-12 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54 +PushBackCall)), + hasParent(compoundStmt(unless(has(ReserveCall)), + has(VectorVarDefStmt +

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments. Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54 +PushBackCall)), + hasParent(compoundStmt(unless(has(ReserveCall)), + has(VectorVarDefStmt +

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54 +PushBackCall)), + hasParent(compoundStmt(unless(has(ReserveCall)), + has(VectorVarDefStmt +

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments. Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54 +PushBackCall)), + hasParent(compoundStmt(unless(has(ReserveCall)), + has(VectorVarDefStmt +

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54 +PushBackCall)), + hasParent(compoundStmt(unless(has(ReserveCall)), + has(VectorVarDefStmt +

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-10 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-10 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-07 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-07 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-06 Thread Eugene Zelenko via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-06 Thread Haojian Wu via Phabricator via cfe-commits
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

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-06 Thread Haojian Wu via Phabricator via cfe-commits
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