aaron.ballman added inline comments.

================
Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+                        PushBackCall)),
+          hasParent(compoundStmt(unless(has(ReserveCall)),
+                                 has(VectorVarDefStmt))))
+          .bind("for_loop"),
----------------
hokein wrote:
> aaron.ballman wrote:
> > I'm really not keen on this. It will catch trivial cases, so there is some 
> > utility, but this will quickly fall apart with anything past the trivial 
> > case.
> The motivation of this check is to find code patterns like `for (int i = 0; i 
> < n; ++i) { v.push_back(i); }` and clean them in our codebase (we have lots 
> of similar cases). 
> [These](https://docs.google.com/document/d/1Bbc-6DlNs6zQujWD5-XOHWbfPJVMG7Z_T27Kv0WcFb4/edit?usp=sharing)
>  are all cases we want to support. Using `hasParent` is a simple and 
> sufficient way to do it IMO.
I'm not convinced of the utility without implementing this in a more sensitive 
way. Have you run this across any large code bases and found that it catches 
issues?


https://reviews.llvm.org/D31757



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to