Skip to content

Commit eb7ebd5

Browse files
authored
[llvm-cov] Remove View member from MCDCView and BranchView (#97734)
These were never actually used, and the way they were constructed doesn't really make sense. Fixes #93798.
1 parent c60b930 commit eb7ebd5

File tree

3 files changed

+26
-54
lines changed

3 files changed

+26
-54
lines changed

llvm/tools/llvm-cov/CodeCoverage.cpp

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,12 @@ class CodeCoverageTool {
100100
const CoverageMapping &Coverage);
101101

102102
/// Create source views for the branches of the view.
103-
void attachBranchSubViews(SourceCoverageView &View, StringRef SourceName,
104-
ArrayRef<CountedRegion> Branches,
105-
const MemoryBuffer &File,
106-
CoverageData &CoverageInfo);
103+
void attachBranchSubViews(SourceCoverageView &View,
104+
ArrayRef<CountedRegion> Branches);
107105

108106
/// Create source views for the MCDC records.
109-
void attachMCDCSubViews(SourceCoverageView &View, StringRef SourceName,
110-
ArrayRef<MCDCRecord> MCDCRecords,
111-
const MemoryBuffer &File, CoverageData &CoverageInfo);
107+
void attachMCDCSubViews(SourceCoverageView &View,
108+
ArrayRef<MCDCRecord> MCDCRecords);
112109

113110
/// Create the source view of a particular function.
114111
std::unique_ptr<SourceCoverageView>
@@ -324,17 +321,13 @@ void CodeCoverageTool::attachExpansionSubViews(
324321
SourceCoverageView::create(Expansion.Function.Name, SourceBuffer.get(),
325322
ViewOpts, std::move(ExpansionCoverage));
326323
attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
327-
attachBranchSubViews(*SubView, Expansion.Function.Name, SubViewBranches,
328-
SourceBuffer.get(), ExpansionCoverage);
324+
attachBranchSubViews(*SubView, SubViewBranches);
329325
View.addExpansion(Expansion.Region, std::move(SubView));
330326
}
331327
}
332328

333329
void CodeCoverageTool::attachBranchSubViews(SourceCoverageView &View,
334-
StringRef SourceName,
335-
ArrayRef<CountedRegion> Branches,
336-
const MemoryBuffer &File,
337-
CoverageData &CoverageInfo) {
330+
ArrayRef<CountedRegion> Branches) {
338331
if (!ViewOpts.ShowBranchCounts && !ViewOpts.ShowBranchPercents)
339332
return;
340333

@@ -348,17 +341,12 @@ void CodeCoverageTool::attachBranchSubViews(SourceCoverageView &View,
348341
while (NextBranch != EndBranch && CurrentLine == NextBranch->LineStart)
349342
ViewBranches.push_back(*NextBranch++);
350343

351-
View.addBranch(CurrentLine, std::move(ViewBranches),
352-
SourceCoverageView::create(SourceName, File, ViewOpts,
353-
std::move(CoverageInfo)));
344+
View.addBranch(CurrentLine, std::move(ViewBranches));
354345
}
355346
}
356347

357348
void CodeCoverageTool::attachMCDCSubViews(SourceCoverageView &View,
358-
StringRef SourceName,
359-
ArrayRef<MCDCRecord> MCDCRecords,
360-
const MemoryBuffer &File,
361-
CoverageData &CoverageInfo) {
349+
ArrayRef<MCDCRecord> MCDCRecords) {
362350
if (!ViewOpts.ShowMCDC)
363351
return;
364352

@@ -374,9 +362,7 @@ void CodeCoverageTool::attachMCDCSubViews(SourceCoverageView &View,
374362
CurrentLine == NextRecord->getDecisionRegion().LineEnd)
375363
ViewMCDCRecords.push_back(*NextRecord++);
376364

377-
View.addMCDCRecord(CurrentLine, std::move(ViewMCDCRecords),
378-
SourceCoverageView::create(SourceName, File, ViewOpts,
379-
std::move(CoverageInfo)));
365+
View.addMCDCRecord(CurrentLine, std::move(ViewMCDCRecords));
380366
}
381367
}
382368

@@ -397,10 +383,8 @@ CodeCoverageTool::createFunctionView(const FunctionRecord &Function,
397383
SourceBuffer.get(), ViewOpts,
398384
std::move(FunctionCoverage));
399385
attachExpansionSubViews(*View, Expansions, Coverage);
400-
attachBranchSubViews(*View, DC.demangle(Function.Name), Branches,
401-
SourceBuffer.get(), FunctionCoverage);
402-
attachMCDCSubViews(*View, DC.demangle(Function.Name), MCDCRecords,
403-
SourceBuffer.get(), FunctionCoverage);
386+
attachBranchSubViews(*View, Branches);
387+
attachMCDCSubViews(*View, MCDCRecords);
404388

405389
return View;
406390
}
@@ -421,10 +405,8 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile,
421405
auto View = SourceCoverageView::create(SourceFile, SourceBuffer.get(),
422406
ViewOpts, std::move(FileCoverage));
423407
attachExpansionSubViews(*View, Expansions, Coverage);
424-
attachBranchSubViews(*View, SourceFile, Branches, SourceBuffer.get(),
425-
FileCoverage);
426-
attachMCDCSubViews(*View, SourceFile, MCDCRecords, SourceBuffer.get(),
427-
FileCoverage);
408+
attachBranchSubViews(*View, Branches);
409+
attachMCDCSubViews(*View, MCDCRecords);
428410
if (!ViewOpts.ShowFunctionInstantiations)
429411
return View;
430412

@@ -446,10 +428,8 @@ CodeCoverageTool::createSourceFileView(StringRef SourceFile,
446428
SubView = SourceCoverageView::create(
447429
Funcname, SourceBuffer.get(), ViewOpts, std::move(SubViewCoverage));
448430
attachExpansionSubViews(*SubView, SubViewExpansions, Coverage);
449-
attachBranchSubViews(*SubView, SourceFile, SubViewBranches,
450-
SourceBuffer.get(), SubViewCoverage);
451-
attachMCDCSubViews(*SubView, SourceFile, SubViewMCDCRecords,
452-
SourceBuffer.get(), SubViewCoverage);
431+
attachBranchSubViews(*SubView, SubViewBranches);
432+
attachMCDCSubViews(*SubView, SubViewMCDCRecords);
453433
}
454434

455435
unsigned FileID = Function->CountedRegions.front().FileID;

llvm/tools/llvm-cov/SourceCoverageView.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,13 @@ void SourceCoverageView::addExpansion(
175175
}
176176

177177
void SourceCoverageView::addBranch(unsigned Line,
178-
SmallVector<CountedRegion, 0> Regions,
179-
std::unique_ptr<SourceCoverageView> View) {
180-
BranchSubViews.emplace_back(Line, std::move(Regions), std::move(View));
178+
SmallVector<CountedRegion, 0> Regions) {
179+
BranchSubViews.emplace_back(Line, std::move(Regions));
181180
}
182181

183-
void SourceCoverageView::addMCDCRecord(
184-
unsigned Line, SmallVector<MCDCRecord, 0> Records,
185-
std::unique_ptr<SourceCoverageView> View) {
186-
MCDCSubViews.emplace_back(Line, std::move(Records), std::move(View));
182+
void SourceCoverageView::addMCDCRecord(unsigned Line,
183+
SmallVector<MCDCRecord, 0> Records) {
184+
MCDCSubViews.emplace_back(Line, std::move(Records));
187185
}
188186

189187
void SourceCoverageView::addInstantiation(

llvm/tools/llvm-cov/SourceCoverageView.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,10 @@ struct InstantiationView {
7070
/// A view that represents one or more branch regions on a given source line.
7171
struct BranchView {
7272
SmallVector<CountedRegion, 0> Regions;
73-
std::unique_ptr<SourceCoverageView> View;
7473
unsigned Line;
7574

76-
BranchView(unsigned Line, SmallVector<CountedRegion, 0> Regions,
77-
std::unique_ptr<SourceCoverageView> View)
78-
: Regions(std::move(Regions)), View(std::move(View)), Line(Line) {}
75+
BranchView(unsigned Line, SmallVector<CountedRegion, 0> Regions)
76+
: Regions(std::move(Regions)), Line(Line) {}
7977

8078
unsigned getLine() const { return Line; }
8179

@@ -87,12 +85,10 @@ struct BranchView {
8785
/// A view that represents one or more MCDC regions on a given source line.
8886
struct MCDCView {
8987
SmallVector<MCDCRecord, 0> Records;
90-
std::unique_ptr<SourceCoverageView> View;
9188
unsigned Line;
9289

93-
MCDCView(unsigned Line, SmallVector<MCDCRecord, 0> Records,
94-
std::unique_ptr<SourceCoverageView> View)
95-
: Records(std::move(Records)), View(std::move(View)), Line(Line) {}
90+
MCDCView(unsigned Line, SmallVector<MCDCRecord, 0> Records)
91+
: Records(std::move(Records)), Line(Line) {}
9692

9793
unsigned getLine() const { return Line; }
9894

@@ -303,12 +299,10 @@ class SourceCoverageView {
303299
std::unique_ptr<SourceCoverageView> View);
304300

305301
/// Add a branch subview to this view.
306-
void addBranch(unsigned Line, SmallVector<CountedRegion, 0> Regions,
307-
std::unique_ptr<SourceCoverageView> View);
302+
void addBranch(unsigned Line, SmallVector<CountedRegion, 0> Regions);
308303

309304
/// Add an MCDC subview to this view.
310-
void addMCDCRecord(unsigned Line, SmallVector<MCDCRecord, 0> Records,
311-
std::unique_ptr<SourceCoverageView> View);
305+
void addMCDCRecord(unsigned Line, SmallVector<MCDCRecord, 0> Records);
312306

313307
/// Print the code coverage information for a specific portion of a
314308
/// source file to the output stream.

0 commit comments

Comments
 (0)