diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -130,6 +130,9 @@ CoverageFiltersMatchAll Filters; CoverageFilters IgnoreFilenameFilters; + /// True if InputSourceFiles are provided. + bool HasInputSourceFiles; + /// The path to the indexed profile. std::string PGOFilename; @@ -777,6 +780,8 @@ } } + HasInputSourceFiles = !InputSourceFiles.empty(); + // IgnoreFilenameFilters are applied even when InputSourceFiles specified. for (const std::string &File : InputSourceFiles) collectPaths(File); @@ -895,7 +900,7 @@ auto Printer = CoveragePrinter::create(ViewOpts); - if (SourceFiles.empty()) + if (SourceFiles.empty() && !HasInputSourceFiles) // Get the source files from the function coverage mapping. for (StringRef Filename : Coverage->getUniqueSourceFiles()) { if (!IgnoreFilenameFilters.matchesFilename(Filename))