[PATCH] D148639: [NFC][clang] Fix static analyzer concerns about AUTO_CAUSES_COPY

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 19 05:37:02 PDT 2023


steakhal added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1053
 
-  for (auto I : CleanedState->get<ObjectsUnderConstruction>()) {
+  for (const auto &I : CleanedState->get<ObjectsUnderConstruction>()) {
     if (SymbolRef Sym = I.second.getAsSymbol())
----------------
I think this is supposed to be just some lightweight handle: some discriminator and pointer under the hood. `sizeof(I)`
 is just 40 bytes. Another point is that the copy construction is not customized, so the `sizeof` for such objects should be a good proxy for estimating how costly the copy is.

For me personally, if it fits into a cacheline (on `x86_64` I think its 64 bytes) (and ~trivially-copyable) then it should've probably taken by value.
I haven't measured this theory, so take it with a pinch of salt.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148639/new/

https://reviews.llvm.org/D148639



More information about the cfe-commits mailing list