]> granicus.if.org Git - clang/commitdiff
[SourceLocations] Use stronger sort predicate to remove non-deterministic ordering
authorMandeep Singh Grang <mgrang@codeaurora.org>
Wed, 29 Nov 2017 20:55:13 +0000 (20:55 +0000)
committerMandeep Singh Grang <mgrang@codeaurora.org>
Wed, 29 Nov 2017 20:55:13 +0000 (20:55 +0000)
Summary:
This fixes the following failure uncovered by D39245:
  Clang :: Index/getcursor-preamble.m

Reviewers: gbenyei, akyrtzi, bkramer, arphaman

Reviewed By: arphaman

Subscribers: arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D40618

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319357 91177308-0d34-0410-b5e6-96231b3b80d8

tools/libclang/CIndex.cpp

index 98532fe525f202bbeb9d3efcc95d4c40e62832a6..455151f0fc6977fb1a12a04c133a73e02438203a 100644 (file)
@@ -1025,8 +1025,9 @@ bool CursorVisitor::VisitObjCContainerDecl(ObjCContainerDecl *D) {
             [&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.