]> granicus.if.org Git - llvm/commitdiff
[llvm-cov] Use a stable sort on sub-views
authorVedant Kumar <vsk@apple.com>
Tue, 24 Oct 2017 20:03:37 +0000 (20:03 +0000)
committerVedant Kumar <vsk@apple.com>
Tue, 24 Oct 2017 20:03:37 +0000 (20:03 +0000)
We need to use a stable sort on instantiation and expansion sub-views to
produce consistent output. Fortunately, we've gotten lucky and the tests
have checks for the stable order.

This is needed to unblock D39245. Once that lands, we'll have better
test coverage for sort non-determinism.

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

tools/llvm-cov/SourceCoverageView.cpp

index f2e8788fec84c9c759f9e748157043b3f46e6622..31ab1325c7b7addae665fa9498189513158b3ac0 100644 (file)
@@ -178,8 +178,8 @@ void SourceCoverageView::print(raw_ostream &OS, bool WholeFile,
 
   // We need the expansions and instantiations sorted so we can go through them
   // while we iterate lines.
-  std::sort(ExpansionSubViews.begin(), ExpansionSubViews.end());
-  std::sort(InstantiationSubViews.begin(), InstantiationSubViews.end());
+  std::stable_sort(ExpansionSubViews.begin(), ExpansionSubViews.end());
+  std::stable_sort(InstantiationSubViews.begin(), InstantiationSubViews.end());
   auto NextESV = ExpansionSubViews.begin();
   auto EndESV = ExpansionSubViews.end();
   auto NextISV = InstantiationSubViews.begin();