================
@@ -50,6 +50,17 @@ unsigned clang_equalLocations(CXSourceLocation loc1, 
CXSourceLocation loc2) {
           loc1.int_data == loc2.int_data);
 }
 
+unsigned clang_lessThanLocations(CXSourceLocation loc1, CXSourceLocation loc2) 
{
+  const SourceLocation Loc1 = 
SourceLocation::getFromRawEncoding(loc1.int_data);
+  const SourceLocation Loc2 = 
SourceLocation::getFromRawEncoding(loc2.int_data);
+
+  const SourceManager &SM =
+      *static_cast<const SourceManager *>(loc1.ptr_data[0]);
+  // Use the appropriate SourceManager method here rather than operator< 
because
+  // ordering is meaningful only if LHS and RHS have the same FileID
----------------
Endilll wrote:

Can you also remove the following TODO 
https://github.com/llvm/llvm-project/blob/2b959bd7f21bc7550a99fb160997002b7e4f1b62/clang/lib/Basic/SourceManager.cpp#L2041-L2042
because we now depend on this check, and update it's documentation to reflect 
that? It would also make sense to reference libclang as a user where such 
"impossible" inputs can come from.

https://github.com/llvm/llvm-project/pull/101802
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to