mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-05 09:24:28 +00:00
llvm-cov: Rework the API for getting the coverage of a file (NFC)
This encapsulates how we handle the coverage regions of a file or function. In the old model, the user had to deal with nested regions, so they needed to maintain their own auxiliary data structures to get any useful information out of this. The new API provides a sequence of non-overlapping coverage segments, which makes it possible to render coverage information in a single pass and avoids a fair amount of extra work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217975 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -284,12 +284,12 @@ void CodeCoverageTool::createExpansionSubView(
|
||||
return;
|
||||
auto SubView = llvm::make_unique<SourceCoverageView>(SourceBuffer.get(),
|
||||
Parent.getOptions());
|
||||
SourceCoverageDataManager RegionManager;
|
||||
auto RegionManager = llvm::make_unique<SourceCoverageDataManager>();
|
||||
for (const auto &CR : Function.CountedRegions) {
|
||||
if (CR.FileID == ExpandedRegion.ExpandedFileID)
|
||||
RegionManager.insert(CR);
|
||||
RegionManager->insert(CR);
|
||||
}
|
||||
SubView->load(RegionManager);
|
||||
SubView->load(std::move(RegionManager));
|
||||
createExpansionSubViews(*SubView, ExpandedRegion.ExpandedFileID, Function);
|
||||
Parent.addExpansion(ExpandedRegion, std::move(SubView));
|
||||
}
|
||||
@ -311,16 +311,16 @@ void CodeCoverageTool::createExpansionSubViews(
|
||||
void CodeCoverageTool::createInstantiationSubView(
|
||||
StringRef SourceFile, const FunctionCoverageMapping &Function,
|
||||
SourceCoverageView &View) {
|
||||
SourceCoverageDataManager RegionManager;
|
||||
auto RegionManager = llvm::make_unique<SourceCoverageDataManager>();
|
||||
SmallSet<unsigned, 8> InterestingFileIDs;
|
||||
if (!gatherInterestingFileIDs(SourceFile, Function, InterestingFileIDs))
|
||||
return;
|
||||
// Get the interesting regions
|
||||
for (const auto &CR : Function.CountedRegions) {
|
||||
if (InterestingFileIDs.count(CR.FileID))
|
||||
RegionManager.insert(CR);
|
||||
RegionManager->insert(CR);
|
||||
}
|
||||
View.load(RegionManager);
|
||||
View.load(std::move(RegionManager));
|
||||
unsigned MainFileID;
|
||||
if (findMainViewFileID(SourceFile, Function, MainFileID))
|
||||
return;
|
||||
@ -331,7 +331,7 @@ bool CodeCoverageTool::createSourceFileView(
|
||||
StringRef SourceFile, SourceCoverageView &View,
|
||||
ArrayRef<FunctionCoverageMapping> FunctionMappingRecords,
|
||||
bool UseOnlyRegionsInMainFile) {
|
||||
SourceCoverageDataManager RegionManager;
|
||||
auto RegionManager = llvm::make_unique<SourceCoverageDataManager>();
|
||||
FunctionInstantiationSetCollector InstantiationSetCollector;
|
||||
|
||||
for (const auto &Function : FunctionMappingRecords) {
|
||||
@ -347,14 +347,14 @@ bool CodeCoverageTool::createSourceFileView(
|
||||
// Get the interesting regions
|
||||
for (const auto &CR : Function.CountedRegions) {
|
||||
if (InterestingFileIDs.count(CR.FileID))
|
||||
RegionManager.insert(CR);
|
||||
RegionManager->insert(CR);
|
||||
}
|
||||
InstantiationSetCollector.insert(Function, MainFileID);
|
||||
createExpansionSubViews(View, MainFileID, Function);
|
||||
}
|
||||
if (RegionManager.getSourceRegions().empty())
|
||||
if (RegionManager->getCoverageSegments().empty())
|
||||
return true;
|
||||
View.load(RegionManager);
|
||||
View.load(std::move(RegionManager));
|
||||
// Show instantiations
|
||||
if (!ViewOpts.ShowFunctionInstantiations)
|
||||
return false;
|
||||
@ -626,7 +626,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
|
||||
ViewOpts.colored_ostream(outs(), raw_ostream::CYAN)
|
||||
<< Function.Name << " from " << SourceFile << ":";
|
||||
outs() << "\n";
|
||||
mainView.render(outs());
|
||||
mainView.render(outs(), /*WholeFile=*/false);
|
||||
if (FunctionMappingRecords.size() > 1)
|
||||
outs() << "\n";
|
||||
}
|
||||
@ -663,7 +663,7 @@ int CodeCoverageTool::show(int argc, const char **argv,
|
||||
ViewOpts.colored_ostream(outs(), raw_ostream::CYAN) << SourceFile << ":";
|
||||
outs() << "\n";
|
||||
}
|
||||
mainView.render(outs());
|
||||
mainView.render(outs(), /*Wholefile=*/true);
|
||||
if (SourceFiles.size() > 1)
|
||||
outs() << "\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user