diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:31:46 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:37:19 +0000 |
| commit | e8d8bef961a50d4dc22501cde4fb9fb0be1b2532 (patch) | |
| tree | 94f04805f47bb7c59ae29690d8952b6074fff602 /contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewText.cpp | |
| parent | bb130ff39747b94592cb26d71b7cb097b9a4ea6b (diff) | |
| parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewText.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewText.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewText.cpp b/contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewText.cpp index fcabee2ee69d..948414a4f995 100644 --- a/contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewText.cpp +++ b/contrib/llvm-project/llvm/tools/llvm-cov/SourceCoverageViewText.cpp @@ -10,11 +10,12 @@ /// //===----------------------------------------------------------------------===// -#include "CoverageReport.h" #include "SourceCoverageViewText.h" +#include "CoverageReport.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Format.h" using namespace llvm; @@ -222,6 +223,53 @@ void SourceCoverageViewText::renderExpansionView(raw_ostream &OS, /*ShowTitle=*/false, ViewDepth + 1); } +void SourceCoverageViewText::renderBranchView(raw_ostream &OS, BranchView &BRV, + unsigned ViewDepth) { + // Render the child subview. + if (getOptions().Debug) + errs() << "Branch at line " << BRV.getLine() << '\n'; + + for (const auto &R : BRV.Regions) { + double TruePercent = 0.0; + double FalsePercent = 0.0; + unsigned Total = R.ExecutionCount + R.FalseExecutionCount; + + if (!getOptions().ShowBranchCounts && Total != 0) { + TruePercent = ((double)(R.ExecutionCount) / (double)Total) * 100.0; + FalsePercent = ((double)(R.FalseExecutionCount) / (double)Total) * 100.0; + } + + renderLinePrefix(OS, ViewDepth); + OS << " Branch (" << R.LineStart << ":" << R.ColumnStart << "): ["; + + if (R.Folded) { + OS << "Folded - Ignored]\n"; + continue; + } + + colored_ostream(OS, raw_ostream::RED, + getOptions().Colors && !R.ExecutionCount, + /*Bold=*/false, /*BG=*/true) + << "True"; + + if (getOptions().ShowBranchCounts) + OS << ": " << formatCount(R.ExecutionCount) << ", "; + else + OS << ": " << format("%0.2f", TruePercent) << "%, "; + + colored_ostream(OS, raw_ostream::RED, + getOptions().Colors && !R.FalseExecutionCount, + /*Bold=*/false, /*BG=*/true) + << "False"; + + if (getOptions().ShowBranchCounts) + OS << ": " << formatCount(R.FalseExecutionCount); + else + OS << ": " << format("%0.2f", FalsePercent) << "%"; + OS << "]\n"; + } +} + void SourceCoverageViewText::renderInstantiationView(raw_ostream &OS, InstantiationView &ISV, unsigned ViewDepth) { |
