[PATCH] D135192: Fix incorrect check for running out of source locations.

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 18 13:48:14 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b773dcd2de0: Fix incorrect check for running out of source locations. (authored by ppluzhnikov, committed by dblaikie).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135192

Files:
  clang/lib/Basic/SourceManager.cpp


Index: clang/lib/Basic/SourceManager.cpp
===================================================================
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -454,8 +454,10 @@
                                          SourceLocation::UIntTy TotalSize) {
   assert(ExternalSLocEntries && "Don't have an external sloc source");
   // Make sure we're not about to run out of source locations.
-  if (CurrentLoadedOffset - TotalSize < NextLocalOffset)
+  if (CurrentLoadedOffset < TotalSize ||
+      CurrentLoadedOffset - TotalSize < NextLocalOffset) {
     return std::make_pair(0, 0);
+  }
   LoadedSLocEntryTable.resize(LoadedSLocEntryTable.size() + NumSLocEntries);
   SLocEntryLoaded.resize(LoadedSLocEntryTable.size());
   CurrentLoadedOffset -= TotalSize;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135192.468680.patch
Type: text/x-patch
Size: 790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221018/c698c88b/attachment.bin>


More information about the cfe-commits mailing list