Skip to content

Commit

Permalink
[Coverage][llvm-cov] (wip) print function names in MC/DC views indica…
Browse files Browse the repository at this point in the history
…ting which instantiation this one is from
  • Loading branch information
whentojump committed Mar 6, 2024
1 parent 72313b4 commit 251082f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ struct MCDCRecord {
using LineColPairMap = llvm::DenseMap<unsigned, LineColPair>;
using FileIDMap = llvm::DenseMap<unsigned, unsigned>;

// FIXME should not be public
std::string FuncName;

private:
CounterMappingRegion Region;
TestVectors TV;
Expand Down
12 changes: 10 additions & 2 deletions llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,9 +1405,17 @@ CoverageData CoverageMapping::getCoverageForFile(StringRef Filename) const {
if (FileIDs.test(CR.FileID) && (CR.FileID == CR.ExpandedFileID))
FileCoverage.BranchRegions.push_back(CR);
// Capture MCDC records specific to the function.
for (const auto &MR : Function.MCDCRecords)
if (FileIDs.test(MR.getDecisionRegion().FileID))
// FIXME This is so far the most convenient place I can find where the function
// name is easily available. Can this assignment/copy happen even earlier?
// 1. Earlier in visualization, e.g. ctor of MCDCRecord, so that here we
// continue using const and &
// 2. Front end
for (auto MR : Function.MCDCRecords) {
if (FileIDs.test(MR.getDecisionRegion().FileID)) {
MR.FuncName = Function.Name;
FileCoverage.MCDCRecords.push_back(MR);
}
}
}

LLVM_DEBUG(dbgs() << "Emitting segments for file: " << Filename << "\n");
Expand Down
1 change: 1 addition & 0 deletions llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ void SourceCoverageViewHTML::renderMCDCView(raw_ostream &OS, MCDCView &MRV,
for (auto &Record : MRV.Records) {
OS << BeginExpansionDiv;
OS << BeginPre;
OS << " " << Record.FuncName << "\n\n";
OS << " MC/DC Decision Region (";

// Display Line + Column information.
Expand Down
5 changes: 5 additions & 0 deletions llvm/tools/llvm-cov/SourceCoverageViewText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ void SourceCoverageViewText::renderMCDCView(raw_ostream &OS, MCDCView &MRV,
renderLinePrefix(OS, ViewDepth);
OS << "\n";

renderLinePrefix(OS, ViewDepth);
OS << " " << Record.FuncName << "\n";
renderLinePrefix(OS, ViewDepth);
OS << "\n";

// Display MC/DC Information.
renderLinePrefix(OS, ViewDepth);
OS << " Number of Conditions: " << Record.getNumConditions() << "\n";
Expand Down

0 comments on commit 251082f

Please sign in to comment.