[llvm] r229217 - llvm-cov: Actually use the command line arguments when reporting
Justin Bogner
mail at justinbogner.com
Fri Feb 13 18:05:06 PST 2015
Author: bogner
Date: Fri Feb 13 20:05:05 2015
New Revision: 229217
URL: http://llvm.org/viewvc/llvm-project?rev=229217&view=rev
Log:
llvm-cov: Actually use the command line arguments when reporting
This code didn't really make sense as is. If a filename is passed in,
the user obviously wants the coverage *for that file*, not *for
everything*.
Modified:
llvm/trunk/test/tools/llvm-cov/Inputs/report.covmapping
llvm/trunk/test/tools/llvm-cov/report.cpp
llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
llvm/trunk/tools/llvm-cov/CoverageReport.cpp
llvm/trunk/tools/llvm-cov/CoverageReport.h
Modified: llvm/trunk/test/tools/llvm-cov/Inputs/report.covmapping
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/Inputs/report.covmapping?rev=229217&r1=229216&r2=229217&view=diff
==============================================================================
Binary files - no diff available.
Modified: llvm/trunk/test/tools/llvm-cov/report.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-cov/report.cpp?rev=229217&r1=229216&r2=229217&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-cov/report.cpp (original)
+++ llvm/trunk/test/tools/llvm-cov/report.cpp Fri Feb 13 20:05:05 2015
@@ -1,7 +1,21 @@
-// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -no-colors 2>&1 | FileCheck %s
+// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -no-colors -filename-equivalence 2>&1 | FileCheck %s
+// RUN: llvm-cov report %S/Inputs/report.covmapping -instr-profile %S/Inputs/report.profdata -no-colors -filename-equivalence report.cpp 2>&1 | FileCheck -check-prefix=FILT-NEXT %s
-// CHECK: Filename Regions Miss Cover Functions Executed
-// CHECK: TOTAL 5 2 60.00% 4 75.00%
+// CHECK: Filename Regions Miss Cover Functions Executed
+// CHECK-NEXT: ---
+// CHECK-NEXT: report.cpp 5 2 60.00% 4 75.00%
+// CHECK-NEXT: ---
+// CHECK-NEXT: TOTAL 5 2 60.00% 4 75.00%
+
+// FILT: File 'report.cpp':
+// FILT-NEXT: Name Regions Miss Cover Lines Miss Cover
+// FILT-NEXT: ---
+// FILT-NEXT: _Z3foob 2 1 50.00% 4 2 50.00%
+// FILT-NEXT: _Z3barv 1 0 100.00% 2 0 100.00%
+// FILT-NEXT: _Z4funcv 1 1 0.00% 2 2 0.00%
+// FILT-NEXT: main 1 0 100.00% 5 0 100.00%
+// FILT-NEXT: ---
+// FILT-NEXT: TOTAL 5 2 60.00% 13 4 69.23%
void foo(bool cond) {
if (cond) {
Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=229217&r1=229216&r2=229217&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Fri Feb 13 20:05:05 2015
@@ -324,10 +324,11 @@ int CodeCoverageTool::run(Command Cmd, i
for (const auto &File : InputSourceFiles) {
SmallString<128> Path(File);
- if (std::error_code EC = sys::fs::make_absolute(Path)) {
- errs() << "error: " << File << ": " << EC.message();
- return 1;
- }
+ if (!CompareFilenamesOnly)
+ if (std::error_code EC = sys::fs::make_absolute(Path)) {
+ errs() << "error: " << File << ": " << EC.message();
+ return 1;
+ }
SourceFiles.push_back(Path.str());
}
return 0;
@@ -459,12 +460,10 @@ int CodeCoverageTool::report(int argc, c
return 1;
CoverageReport Report(ViewOpts, std::move(Coverage));
- if (SourceFiles.empty() && Filters.empty()) {
+ if (SourceFiles.empty())
Report.renderFileReports(llvm::outs());
- return 0;
- }
-
- Report.renderFunctionReports(llvm::outs());
+ else
+ Report.renderFunctionReports(SourceFiles, llvm::outs());
return 0;
}
Modified: llvm/trunk/tools/llvm-cov/CoverageReport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageReport.cpp?rev=229217&r1=229216&r2=229217&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageReport.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CoverageReport.cpp Fri Feb 13 20:05:05 2015
@@ -155,9 +155,10 @@ void CoverageReport::render(const Functi
OS << "\n";
}
-void CoverageReport::renderFunctionReports(raw_ostream &OS) {
+void CoverageReport::renderFunctionReports(ArrayRef<std::string> Files,
+ raw_ostream &OS) {
bool isFirst = true;
- for (StringRef Filename : Coverage->getUniqueSourceFiles()) {
+ for (StringRef Filename : Files) {
if (isFirst)
isFirst = false;
else
Modified: llvm/trunk/tools/llvm-cov/CoverageReport.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageReport.h?rev=229217&r1=229216&r2=229217&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageReport.h (original)
+++ llvm/trunk/tools/llvm-cov/CoverageReport.h Fri Feb 13 20:05:05 2015
@@ -32,7 +32,7 @@ public:
std::unique_ptr<coverage::CoverageMapping> Coverage)
: Options(Options), Coverage(std::move(Coverage)) {}
- void renderFunctionReports(raw_ostream &OS);
+ void renderFunctionReports(ArrayRef<std::string> Files, raw_ostream &OS);
void renderFileReports(raw_ostream &OS);
};
More information about the llvm-commits
mailing list