diff options
author | Justin Bogner <mail@justinbogner.com> | 2014-09-17 05:33:20 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2014-09-17 05:33:20 +0000 |
commit | 5e1400a81c45418879776924518f1ff4843f8dd4 (patch) | |
tree | 575cfea3ebd159c6c088f7664fb3fa51d68c30f4 /llvm/tools/llvm-cov/CodeCoverage.cpp | |
parent | b435a4214e5920e56dd2e9fb5fb29bb2d4e98fab (diff) | |
download | bcm5719-llvm-5e1400a81c45418879776924518f1ff4843f8dd4.tar.gz bcm5719-llvm-5e1400a81c45418879776924518f1ff4843f8dd4.zip |
llvm-cov: Distinguish expansion/instantiation from SourceCoverageView
SourceCoverageView currently has "Kind" and a list of child views, all
of which must have either an expansion or an instantiation Kind. In
addition to being an error-prone design, this makes it awkward to
differentiate between the two child types and adds a number of
optionally used members to the type.
Split the subview types into their own separate objects, and maintain
lists of each rather than one combined "Children" list.
llvm-svn: 217940
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
-rw-r--r-- | llvm/tools/llvm-cov/CodeCoverage.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp index f3587c768de..fcc1c6b7d0b 100644 --- a/llvm/tools/llvm-cov/CodeCoverage.cpp +++ b/llvm/tools/llvm-cov/CodeCoverage.cpp @@ -282,8 +282,8 @@ void CodeCoverageTool::createExpansionSubView( getSourceFile(Function.Filenames[ExpandedRegion.ExpandedFileID]); if (!SourceBuffer) return; - auto SubView = llvm::make_unique<SourceCoverageView>( - SourceBuffer.get(), Parent.getOptions(), ExpandedRegion); + auto SubView = llvm::make_unique<SourceCoverageView>(SourceBuffer.get(), + Parent.getOptions()); SourceCoverageDataManager RegionManager; for (const auto &CR : Function.CountedRegions) { if (CR.FileID == ExpandedRegion.ExpandedFileID) @@ -291,7 +291,7 @@ void CodeCoverageTool::createExpansionSubView( } SubView->load(RegionManager); createExpansionSubViews(*SubView, ExpandedRegion.ExpandedFileID, Function); - Parent.addChild(std::move(SubView)); + Parent.addExpansion(ExpandedRegion, std::move(SubView)); } void CodeCoverageTool::createExpansionSubViews( @@ -362,10 +362,18 @@ bool CodeCoverageTool::createSourceFileView( if (InstantiationSet.second.size() < 2) continue; for (auto Function : InstantiationSet.second) { - auto SubView = - llvm::make_unique<SourceCoverageView>(View, Function->Name); + unsigned FileID = Function->CountedRegions.front().FileID; + unsigned Line = 0; + for (const auto &CR : Function->CountedRegions) + if (CR.FileID == FileID) + Line = std::max(CR.LineEnd, Line); + auto SourceBuffer = getSourceFile(Function->Filenames[FileID]); + if (!SourceBuffer) + continue; + auto SubView = llvm::make_unique<SourceCoverageView>(SourceBuffer.get(), + View.getOptions()); createInstantiationSubView(SourceFile, *Function, *SubView); - View.addChild(std::move(SubView)); + View.addInstantiation(Function->Name, Line, std::move(SubView)); } } return false; |