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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 06:14:52 PDT 2023


aaron.ballman 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,
----------------
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.


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