[clang] [clang][modules] Move `SLocEntry` search into `ASTReader` (PR #66966)

Ben Langmuir via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 4 13:56:52 PDT 2023


================
@@ -1444,6 +1444,74 @@ llvm::Error ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
   }
 }
 
+llvm::Expected<SourceLocation::UIntTy>
+ASTReader::readSLocOffset(ModuleFile *F, unsigned Index) {
+  BitstreamCursor &Cursor = F->SLocEntryCursor;
+  SavedStreamPosition SavedPosition(Cursor);
+  if (llvm::Error Err = Cursor.JumpToBit(F->SLocEntryOffsetsBase +
+                                         F->SLocEntryOffsets[Index]))
+    return Err;
----------------
benlangmuir wrote:

I seem to recall that the Error & -> Expected conversion trips a compiler bug in some of our supported compilers. I think you need `std::move(Err)` when returning an l-value.

https://github.com/llvm/llvm-project/pull/66966


More information about the cfe-commits mailing list