[PATCH] D40618: [SourceLocations] Use stronger sort predicate to remove non-deterministic ordering

Mandeep Singh Grang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 12:01:14 PST 2017


mgrang created this revision.

This fixes the following failure uncovered by https://reviews.llvm.org/D39245:

  Clang :: Index/getcursor-preamble.m


Repository:
  rC Clang

https://reviews.llvm.org/D40618

Files:
  tools/libclang/CIndex.cpp


Index: tools/libclang/CIndex.cpp
===================================================================
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1025,8 +1025,9 @@
             [&SM](Decl *A, Decl *B) {
     SourceLocation L_A = A->getLocStart();
     SourceLocation L_B = B->getLocStart();
-    assert(L_A.isValid() && L_B.isValid());
-    return SM.isBeforeInTranslationUnit(L_A, L_B);
+    return L_A != L_B ?
+           SM.isBeforeInTranslationUnit(L_A, L_B) :
+           SM.isBeforeInTranslationUnit(A->getLocEnd(), B->getLocEnd());
   });
 
   // Now visit the decls.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40618.124798.patch
Type: text/x-patch
Size: 595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171129/7ab854be/attachment.bin>


More information about the cfe-commits mailing list