[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 13 22:24:25 PDT 2017


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) {
----------------
aaron.ballman wrote:
> aaron.ballman wrote:
> > I'm not certain what types are being used here. Can you turn `AllVectorVarRefs` into something with an explicit type so that I can know what `Ref`'s type is?
> I may not have been clear -- I don't mean that the variable name should contain type information, I mean that the type should not be automatically deduced. We only use `auto` when the type is spelled explicitly in the initialization or is otherwise obvious from context (like range-based for loops).
I'd prefer to use `auto` to initialize `AllVectorVarRefExprs`, as its type is `SmallPtrSet<const DeclRefExpr *, 16>`, which is a long and noisy name. Using `auto` can increases readability here.


https://reviews.llvm.org/D31757





More information about the cfe-commits mailing list