[llvm] r316490 - [llvm-cov] Use a stable sort on sub-views

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 13:03:37 PDT 2017


Author: vedantk
Date: Tue Oct 24 13:03:37 2017
New Revision: 316490

URL: http://llvm.org/viewvc/llvm-project?rev=316490&view=rev
Log:
[llvm-cov] Use a stable sort on sub-views

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.

Modified:
    llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp

Modified: llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp?rev=316490&r1=316489&r2=316490&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageView.cpp Tue Oct 24 13:03:37 2017
@@ -178,8 +178,8 @@ void SourceCoverageView::print(raw_ostre
 
   // 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();




More information about the llvm-commits mailing list