[PATCH] D50447: [clang-tidy] Add a whitelistClasses option in performance-for-range-copy check.

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 8 08:08:39 PDT 2018


JonasToth added a comment.

> But in our codebase, we have code intended to use like below, and it is in base library, and is used widely. I think it makes sense to whitelist this class in our internal configuration.
> 
>   for (auto _ : state) {
>      ... // no `_` being referenced in the for-loop body
>   }

I see.



================
Comment at: clang-tidy/performance/ForRangeCopyCheck.cpp:93
     return false;
   if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
           .isMutated(&LoopVar))
----------------
Adding a `..IsMutated(&LoopVar) && IsReferenced(ForScope, LoopVar))` here should fix the warning as well.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50447





More information about the cfe-commits mailing list