[PATCH] D123436: [Clang] Pass llvm::BitstreamCursor by reference. NFC

Jun Zhang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 9 04:41:52 PDT 2022


junaire added inline comments.


================
Comment at: clang/lib/Serialization/GlobalModuleIndex.cpp:130
     std::unique_ptr<llvm::MemoryBuffer> IndexBuffer,
-    llvm::BitstreamCursor Cursor)
+    llvm::BitstreamCursor &Cursor)
     : Buffer(std::move(IndexBuffer)), IdentifierIndex(), NumIdentifierLookups(),
----------------
RKSimon wrote:
> You're not passing this as a const, so the calling function's Cursor will be updated - this doesn't sound generally safe to me - what about a move?
> You're not passing this as a const, so the calling function's Cursor will be updated - this doesn't sound generally safe to me - what about a move?

IIUC, `GlobalModuleIndex::GlobalModuleIndex` is a private function that has only been called by `GlobalModuleIndex::readIndex`, and the `Cursor` object has only one consumer (`GlobalModuleIndex::readIndex`), so I guess there should not be any unsafe concern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123436



More information about the cfe-commits mailing list