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;
}
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()) {
"greater than the given threshold"),
cl::cat(FilteringCategory));
- enum Colors { Auto, Always, Never };
- cl::opt<Colors> 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<cl::boolOrDefault> 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()) {