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(


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(
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to