From: Mandeep Singh Grang Date: Wed, 29 Nov 2017 20:55:13 +0000 (+0000) Subject: [SourceLocations] Use stronger sort predicate to remove non-deterministic ordering X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25c021962d9747fe4fde8ed3cf52da01c7e67348;p=clang [SourceLocations] Use stronger sort predicate to remove non-deterministic ordering 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 --- diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 98532fe525..455151f0fc 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -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.