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

Daniel Grumberg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 11 04:46:45 PDT 2023


dang 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,
----------------
RKSimon wrote:
> 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.
Yeah this certainly doesn't look right, since the new version tries to move from the const reference.


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