diff options
author | Justin Bogner <mail@justinbogner.com> | 2015-05-04 04:09:38 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2015-05-04 04:09:38 +0000 |
commit | 65337d1f3a2b95b600aed832b10cb84da4422a15 (patch) | |
tree | b9d34d2a7da5e19c2ad18c462cb50049434d4bef | |
parent | 0da0d4a948189386e83bfd9e3a9843df7744a734 (diff) | |
download | bcm5719-llvm-65337d1f3a2b95b600aed832b10cb84da4422a15.tar.gz bcm5719-llvm-65337d1f3a2b95b600aed832b10cb84da4422a15.zip |
llvm-cov: Warn if object file is newer than profile
Looking at coverage with an out of date profile can be confusing.
Provide a little hint that something might be wrong.
llvm-svn: 236408
-rw-r--r-- | llvm/tools/llvm-cov/CodeCoverage.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index 0331a02dfcc..f85f3b13b67 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -195,7 +195,20 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile, return View; } +static bool modifiedTimeGT(StringRef LHS, StringRef RHS) { + sys::fs::file_status Status; + if (sys::fs::status(LHS, Status)) + return false; + auto LHSTime = Status.getLastModificationTime(); + if (sys::fs::status(RHS, Status)) + return false; + auto RHSTime = Status.getLastModificationTime(); + return LHSTime > RHSTime; +} + std::unique_ptr<CoverageMapping> CodeCoverageTool::load() { + if (modifiedTimeGT(ObjectFilename, PGOFilename)) + errs() << "warning: profile data may be out of date - object is newer\n"; auto CoverageOrErr = CoverageMapping::load(ObjectFilename, PGOFilename, CoverageArch); if (std::error_code EC = CoverageOrErr.getError()) { |