]> granicus.if.org Git - clang/commitdiff
[libclang] Determinize order of platform availability attrs
authorReid Kleckner <rnk@google.com>
Fri, 4 Aug 2017 21:52:25 +0000 (21:52 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 4 Aug 2017 21:52:25 +0000 (21:52 +0000)
Previously this code was doing std::sort on IdentifierInfo pointers. Now
it sorts alphabetically by platform name.

This should de-flake clang/test/Index/availability.c, which was failing
non-deterministically for me.

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

tools/libclang/CIndex.cpp

index 1815fdf5bd8ee45d99e660bf79e66a2c2b10ca8f..ca21b6c6f68fa13bad43b5bba48ab083f260f82a 100644 (file)
@@ -7303,7 +7303,8 @@ static void getCursorPlatformAvailabilityForDecl(
 
   std::sort(AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
             [](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
-              return LHS->getPlatform() > RHS->getPlatform();
+              return LHS->getPlatform()->getName() <
+                     RHS->getPlatform()->getName();
             });
   ASTContext &Ctx = D->getASTContext();
   auto It = std::unique(