summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-05-04 04:09:38 +0000
committerJustin Bogner <mail@justinbogner.com>2015-05-04 04:09:38 +0000
commit65337d1f3a2b95b600aed832b10cb84da4422a15 (patch)
treeb9d34d2a7da5e19c2ad18c462cb50049434d4bef
parent0da0d4a948189386e83bfd9e3a9843df7744a734 (diff)
downloadbcm5719-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.cpp13
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()) {
OpenPOWER on IntegriCloud