[PATCH] D147901: [NFC][CLANG][API] Fix coverity remarks about large copies by values

Simon Pilgrim via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 06:27:03 PDT 2023


RKSimon added inline comments.


================
Comment at: clang/include/clang/ExtractAPI/API.h:138
   APIRecord(RecordKind Kind, StringRef USR, StringRef Name,
-            PresumedLoc Location, AvailabilitySet Availabilities,
+            PresumedLoc Location, const AvailabilitySet &Availabilities,
             LinkageInfo Linkage, const DocComment &Comment,
----------------
aaron.ballman wrote:
> A lot of these changes look to be regressions, so I think Coverity is incorrect to flag these. The old code is passing an `AvailabilitySet` by value because it's doing a move operation on initialization: `Availabilities(std::move(Availabilities))`. Making this into a const reference defeats that optimization because you can't steal resources from a const object (so this turns a move into a copy).
> 
> You should look through the rest of the patch for similar problematic changes.
I've never been sure whether coverity is being particularly poor at recognising the std::move pattern or particularly smart at realising it can't occur for some reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147901



More information about the cfe-commits mailing list