[PATCH] D59934: Compare SourceLocations from different TUs by FileID

Endre Fülöp via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 07:40:19 PDT 2019


gamesh411 created this revision.
Herald added subscribers: cfe-commits, jdoerfert, Szelethus, dkrupp.
Herald added a project: clang.

The comparison of SourceLocations is extended to handle locations from different
translation units, making the comparison based on the corresponding FileID.


Repository:
  rC Clang

https://reviews.llvm.org/D59934

Files:
  lib/Basic/SourceManager.cpp


Index: lib/Basic/SourceManager.cpp
===================================================================
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -2035,7 +2035,10 @@
       return LIsScratch;
     return LOffs.second < ROffs.second;
   }
-  llvm_unreachable("Unsortable locations found");
+
+  // If SourceLocations originate from different TUs, but cannot be handled
+  // by one of the previous cases, just compare the FileIDs directly.
+  return LOffs.first < ROffs.first;
 }
 
 std::pair<bool, bool> SourceManager::isInTheSameTranslationUnit(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59934.192633.patch
Type: text/x-patch
Size: 571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190328/3cdc2ddb/attachment.bin>


More information about the cfe-commits mailing list