X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-cov%2FCodeCoverage.cpp;h=4ff53301881d1b55069d71a99ceb1abccf4d2b9c;hb=69266c39908276c9ba636160d1ee9d985506ac98;hp=c9bb7cefa064ef822736a05f26b104391aa23f9f;hpb=dd08f96ac74f3db11bd30ccaab7ee07d9590ed92;p=oota-llvm.git diff --git a/tools/llvm-cov/CodeCoverage.cpp b/tools/llvm-cov/CodeCoverage.cpp index c9bb7cefa06..4ff53301881 100644 --- a/tools/llvm-cov/CodeCoverage.cpp +++ b/tools/llvm-cov/CodeCoverage.cpp @@ -116,8 +116,7 @@ CodeCoverageTool::getSourceFile(StringRef SourceFile) { error(EC.message(), SourceFile); return EC; } - LoadedSourceFiles.push_back( - std::make_pair(SourceFile, std::move(Buffer.get()))); + LoadedSourceFiles.emplace_back(SourceFile, std::move(Buffer.get())); return *LoadedSourceFiles.back().second; } @@ -195,7 +194,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 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()) { @@ -294,23 +306,18 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) { "greater than the given threshold"), cl::cat(FilteringCategory)); - enum Colors { Auto, Always, Never }; - cl::opt Color( - "color", cl::desc("Configure color output:"), cl::init(Colors::Auto), - cl::values(clEnumValN(Colors::Auto, "auto", - "Enable color if stdout seems to support it"), - clEnumValN(Colors::Always, "always", "Enable color"), - clEnumValN(Colors::Never, "never", "Disable color"), - clEnumValEnd)); + cl::opt UseColor( + "use-color", cl::desc("Emit colored output (default=autodetect)"), + cl::init(cl::BOU_UNSET)); auto commandLineParser = [&, this](int argc, const char **argv) -> int { cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n"); ViewOpts.Debug = DebugDump; CompareFilenamesOnly = FilenameEquivalence; - ViewOpts.Colors = - Color == Colors::Always || - (Color == Colors::Auto && sys::Process::StandardOutHasColors()); + ViewOpts.Colors = UseColor == cl::BOU_UNSET + ? sys::Process::StandardOutHasColors() + : UseColor == cl::BOU_TRUE; // Create the function filters if (!NameFilters.empty() || !NameRegexFilters.empty()) {