[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 28 23:20:39 PDT 2022
njames93 added a comment.
I have a feeling the default should be to only warm in loops otherwise this could get noisy. Though setting it as the default you'd likely want to change the name to something along the lines of WarmOutsideLoops.
================
Comment at: clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.cpp:70
+ const auto IsWithinLoop = cxxMemberCallExpr(
+ hasAncestor(stmt(anyOf(forStmt(), whileStmt(), doStmt())).bind("loop")),
+ // An easy false positive case: the variable is declared in the loop.
----------------
Rather than checking for an ancestor. Use the mapAnyOf matcher to check for a descendant in a loops body, this would remove the need for the false positive check below.
Also you aren't checking a ranged for.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131939/new/
https://reviews.llvm.org/D131939
More information about the cfe-commits
mailing list