diff options
| author | Vedant Kumar <vsk@apple.com> | 2017-04-26 00:16:10 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2017-04-26 00:16:10 +0000 |
| commit | 77deb5c7880c18c2e1112e508c1091bc3d872516 (patch) | |
| tree | 0ca032935efd61e273811c6cb6defc78c4696450 /llvm/lib | |
| parent | c5e84f14a22c8b5ea6e43f4ce675876afe67f2b5 (diff) | |
| download | bcm5719-llvm-77deb5c7880c18c2e1112e508c1091bc3d872516.tar.gz bcm5719-llvm-77deb5c7880c18c2e1112e508c1091bc3d872516.zip | |
[gcov] Sort file info before printing it
The order in which GCOV file info is printed depends on the string hash
function. This makes some GCOV tests brittle, because the tests must be
updated whenever the hash function changes.
Sort the filenames before printing out the file info to solve the
problem. This should be relatively cheap.
Differential Revision: https://reviews.llvm.org/D32512
llvm-svn: 301371
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/GCOV.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/IR/GCOV.cpp b/llvm/lib/IR/GCOV.cpp index ba92a91cc91..d4b45522822 100644 --- a/llvm/lib/IR/GCOV.cpp +++ b/llvm/lib/IR/GCOV.cpp @@ -589,8 +589,12 @@ FileInfo::openCoveragePath(StringRef CoveragePath) { /// print - Print source files with collected line count information. void FileInfo::print(raw_ostream &InfoOS, StringRef MainFilename, StringRef GCNOFile, StringRef GCDAFile) { - for (const auto &LI : LineInfo) { - StringRef Filename = LI.first(); + SmallVector<StringRef, 4> Filenames; + for (const auto &LI : LineInfo) + Filenames.push_back(LI.first()); + std::sort(Filenames.begin(), Filenames.end()); + + for (StringRef Filename : Filenames) { auto AllLines = LineConsumer(Filename); std::string CoveragePath = getCoveragePath(Filename, MainFilename); @@ -603,7 +607,7 @@ void FileInfo::print(raw_ostream &InfoOS, StringRef MainFilename, CovOS << " -: 0:Runs:" << RunCount << "\n"; CovOS << " -: 0:Programs:" << ProgramCount << "\n"; - const LineData &Line = LI.second; + const LineData &Line = LineInfo[Filename]; GCOVCoverage FileCoverage(Filename); for (uint32_t LineIndex = 0; LineIndex < Line.LastLine || !AllLines.empty(); ++LineIndex) { |

