[llvm] r236408 - llvm-cov: Warn if object file is newer than profile

Justin Bogner mail at justinbogner.com
Sun May 3 21:09:38 PDT 2015


Author: bogner
Date: Sun May  3 23:09:38 2015
New Revision: 236408

URL: http://llvm.org/viewvc/llvm-project?rev=236408&view=rev
Log:
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.

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

Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=236408&r1=236407&r2=236408&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Sun May  3 23:09:38 2015
@@ -195,7 +195,20 @@ CodeCoverageTool::createSourceFileView(S
   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()) {





More information about the llvm-commits mailing list