[llvm] r217416 - llvm-cov: Rename MappingRegion to coverage::CountedRegion (NFC)
Justin Bogner
mail at justinbogner.com
Mon Sep 8 22:32:14 PDT 2014
Author: bogner
Date: Tue Sep 9 00:32:14 2014
New Revision: 217416
URL: http://llvm.org/viewvc/llvm-project?rev=217416&view=rev
Log:
llvm-cov: Rename MappingRegion to coverage::CountedRegion (NFC)
This name was too similar to CoverageMappingRegion, and the type
really belongs in the coverage library anyway.
Modified:
llvm/trunk/include/llvm/ProfileData/CoverageMapping.h
llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp
llvm/trunk/tools/llvm-cov/FunctionCoverageMapping.h
llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.cpp
llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.h
Modified: llvm/trunk/include/llvm/ProfileData/CoverageMapping.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/CoverageMapping.h?rev=217416&r1=217415&r2=217416&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/CoverageMapping.h (original)
+++ llvm/trunk/include/llvm/ProfileData/CoverageMapping.h Tue Sep 9 00:32:14 2014
@@ -173,6 +173,14 @@ struct CounterMappingRegion {
}
};
+/// \brief Associates a source range with an execution count.
+struct CountedRegion : public CounterMappingRegion {
+ uint64_t ExecutionCount;
+
+ CountedRegion(const CounterMappingRegion &R, uint64_t ExecutionCount)
+ : CounterMappingRegion(R), ExecutionCount(ExecutionCount) {}
+};
+
/// \brief A Counter mapping context is used to connect the counters,
/// expressions and the obtained counter values.
class CounterMappingContext {
Modified: llvm/trunk/tools/llvm-cov/CodeCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CodeCoverage.cpp?rev=217416&r1=217415&r2=217416&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CodeCoverage.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CodeCoverage.cpp Tue Sep 9 00:32:14 2014
@@ -53,14 +53,14 @@ class FunctionInstantiationSetCollector
typedef std::vector<const FunctionCoverageMapping *> SetType;
std::unordered_map<uint64_t, SetType> InstantiatedFunctions;
- static KeyType getKey(const MappingRegion &R) {
+ static KeyType getKey(const CountedRegion &R) {
return uint64_t(R.LineStart) | uint64_t(R.ColumnStart) << 32;
}
public:
void insert(const FunctionCoverageMapping &Function, unsigned FileID) {
KeyType Key = 0;
- for (const auto &R : Function.MappingRegions) {
+ for (const auto &R : Function.CountedRegions) {
if (R.FileID == FileID) {
Key = getKey(R);
break;
@@ -119,7 +119,7 @@ public:
/// \brief Create a source view which shows coverage for an expansion
/// of a file.
- void createExpansionSubView(const MappingRegion &ExpandedRegion,
+ void createExpansionSubView(const CountedRegion &ExpandedRegion,
const FunctionCoverageMapping &Function,
SourceCoverageView &Parent);
@@ -197,11 +197,11 @@ findExpandedFileInterestingLineRange(uns
const FunctionCoverageMapping &Function) {
unsigned LineStart = std::numeric_limits<unsigned>::max();
unsigned LineEnd = 0;
- for (const auto &Region : Function.MappingRegions) {
- if (Region.FileID != FileID)
+ for (const auto &CR : Function.CountedRegions) {
+ if (CR.FileID != FileID)
continue;
- LineStart = std::min(Region.LineStart, LineStart);
- LineEnd = std::max(Region.LineEnd, LineEnd);
+ LineStart = std::min(CR.LineStart, LineStart);
+ LineEnd = std::max(CR.LineEnd, LineEnd);
}
return std::make_pair(LineStart, LineEnd);
}
@@ -236,10 +236,10 @@ CodeCoverageTool::findMainViewFileID(Str
if (equivalentFiles(SourceFile, Function.Filenames[I]))
FilenameEquivalence[I] = true;
}
- for (const auto &Region : Function.MappingRegions) {
- if (Region.Kind == MappingRegion::ExpansionRegion &&
- FilenameEquivalence[Region.FileID])
- IsExpandedFile[Region.ExpandedFileID] = true;
+ for (const auto &CR : Function.CountedRegions) {
+ if (CR.Kind == CounterMappingRegion::ExpansionRegion &&
+ FilenameEquivalence[CR.FileID])
+ IsExpandedFile[CR.ExpandedFileID] = true;
}
for (unsigned I = 0, E = Function.Filenames.size(); I < E; ++I) {
if (!FilenameEquivalence[I] || IsExpandedFile[I])
@@ -254,9 +254,9 @@ bool
CodeCoverageTool::findMainViewFileID(const FunctionCoverageMapping &Function,
unsigned &MainViewFileID) {
llvm::SmallVector<bool, 8> IsExpandedFile(Function.Filenames.size(), false);
- for (const auto &Region : Function.MappingRegions) {
- if (Region.Kind == MappingRegion::ExpansionRegion)
- IsExpandedFile[Region.ExpandedFileID] = true;
+ for (const auto &CR : Function.CountedRegions) {
+ if (CR.Kind == CounterMappingRegion::ExpansionRegion)
+ IsExpandedFile[CR.ExpandedFileID] = true;
}
for (unsigned I = 0, E = Function.Filenames.size(); I < E; ++I) {
if (IsExpandedFile[I])
@@ -268,7 +268,7 @@ CodeCoverageTool::findMainViewFileID(con
}
void CodeCoverageTool::createExpansionSubView(
- const MappingRegion &ExpandedRegion,
+ const CountedRegion &ExpandedRegion,
const FunctionCoverageMapping &Function, SourceCoverageView &Parent) {
auto ExpandedLines = findExpandedFileInterestingLineRange(
ExpandedRegion.ExpandedFileID, Function);
@@ -286,9 +286,9 @@ void CodeCoverageTool::createExpansionSu
SourceBuffer.get(), Parent.getOptions(), ExpandedLines.first,
ExpandedLines.second, ExpandedRegion);
SourceCoverageDataManager RegionManager;
- for (const auto &Region : Function.MappingRegions) {
- if (Region.FileID == ExpandedRegion.ExpandedFileID)
- RegionManager.insert(Region);
+ for (const auto &CR : Function.CountedRegions) {
+ if (CR.FileID == ExpandedRegion.ExpandedFileID)
+ RegionManager.insert(CR);
}
SubView->load(RegionManager);
createExpansionSubViews(*SubView, ExpandedRegion.ExpandedFileID, Function);
@@ -300,12 +300,12 @@ void CodeCoverageTool::createExpansionSu
const FunctionCoverageMapping &Function) {
if (!ViewOpts.ShowExpandedRegions)
return;
- for (const auto &Region : Function.MappingRegions) {
- if (Region.Kind != CounterMappingRegion::ExpansionRegion)
+ for (const auto &CR : Function.CountedRegions) {
+ if (CR.Kind != CounterMappingRegion::ExpansionRegion)
continue;
- if (Region.FileID != ViewFileID)
+ if (CR.FileID != ViewFileID)
continue;
- createExpansionSubView(Region, Function, View);
+ createExpansionSubView(CR, Function, View);
}
}
@@ -317,9 +317,9 @@ void CodeCoverageTool::createInstantiati
if (!gatherInterestingFileIDs(SourceFile, Function, InterestingFileIDs))
return;
// Get the interesting regions
- for (const auto &Region : Function.MappingRegions) {
- if (InterestingFileIDs.count(Region.FileID))
- RegionManager.insert(Region);
+ for (const auto &CR : Function.CountedRegions) {
+ if (InterestingFileIDs.count(CR.FileID))
+ RegionManager.insert(CR);
}
View.load(RegionManager);
unsigned MainFileID;
@@ -346,9 +346,9 @@ bool CodeCoverageTool::createSourceFileV
InterestingFileIDs))
continue;
// Get the interesting regions
- for (const auto &Region : Function.MappingRegions) {
- if (InterestingFileIDs.count(Region.FileID))
- RegionManager.insert(Region);
+ for (const auto &CR : Function.CountedRegions) {
+ if (InterestingFileIDs.count(CR.FileID))
+ RegionManager.insert(CR);
}
InstantiationSetCollector.insert(Function, MainFileID);
createExpansionSubViews(View, MainFileID, Function);
@@ -363,7 +363,7 @@ bool CodeCoverageTool::createSourceFileV
if (InstantiationSet.second.size() < 2)
continue;
auto InterestingRange = findExpandedFileInterestingLineRange(
- InstantiationSet.second.front()->MappingRegions.front().FileID,
+ InstantiationSet.second.front()->CountedRegions.front().FileID,
*InstantiationSet.second.front());
for (auto Function : InstantiationSet.second) {
auto SubView = llvm::make_unique<SourceCoverageView>(
@@ -413,7 +413,7 @@ bool CodeCoverageTool::load() {
}
ErrorOr<int64_t> ExecutionCount = Ctx.evaluate(R.Count);
if (ExecutionCount) {
- Function.MappingRegions.push_back(MappingRegion(R, *ExecutionCount));
+ Function.CountedRegions.push_back(CountedRegion(R, *ExecutionCount));
} else if (!RegionError) {
colored_ostream(errs(), raw_ostream::RED)
<< "error: Regions and counters don't match in a function '"
Modified: llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp?rev=217416&r1=217415&r2=217416&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CoverageSummaryInfo.cpp Tue Sep 9 00:32:14 2014
@@ -21,11 +21,11 @@ FunctionCoverageSummary
FunctionCoverageSummary::get(const FunctionCoverageMapping &Function) {
// Compute the region coverage
size_t NumCodeRegions = 0, CoveredRegions = 0;
- for (auto &Region : Function.MappingRegions) {
- if (Region.Kind != CounterMappingRegion::CodeRegion)
+ for (auto &CR : Function.CountedRegions) {
+ if (CR.Kind != CounterMappingRegion::CodeRegion)
continue;
++NumCodeRegions;
- if (Region.ExecutionCount != 0)
+ if (CR.ExecutionCount != 0)
++CoveredRegions;
}
@@ -37,27 +37,27 @@ FunctionCoverageSummary::get(const Funct
// in that particular file
unsigned LineStart = std::numeric_limits<unsigned>::max();
unsigned LineEnd = 0;
- for (auto &Region : Function.MappingRegions) {
- if (Region.FileID != FileID)
+ for (auto &CR : Function.CountedRegions) {
+ if (CR.FileID != FileID)
continue;
- LineStart = std::min(LineStart, Region.LineStart);
- LineEnd = std::max(LineEnd, Region.LineEnd);
+ LineStart = std::min(LineStart, CR.LineStart);
+ LineEnd = std::max(LineEnd, CR.LineEnd);
}
unsigned LineCount = LineEnd - LineStart + 1;
// Get counters
llvm::SmallVector<uint64_t, 16> ExecutionCounts;
ExecutionCounts.resize(LineCount, 0);
- for (auto &Region : Function.MappingRegions) {
- if (Region.FileID != FileID)
+ for (auto &CR : Function.CountedRegions) {
+ if (CR.FileID != FileID)
continue;
// Ignore the lines that were skipped by the preprocessor.
- auto ExecutionCount = Region.ExecutionCount;
- if (Region.Kind == MappingRegion::SkippedRegion) {
- LineCount -= Region.LineEnd - Region.LineStart + 1;
+ auto ExecutionCount = CR.ExecutionCount;
+ if (CR.Kind == CounterMappingRegion::SkippedRegion) {
+ LineCount -= CR.LineEnd - CR.LineStart + 1;
ExecutionCount = 1;
}
- for (unsigned I = Region.LineStart; I <= Region.LineEnd; ++I)
+ for (unsigned I = CR.LineStart; I <= CR.LineEnd; ++I)
ExecutionCounts[I - LineStart] = ExecutionCount;
}
CoveredLines += LineCount - std::count(ExecutionCounts.begin(),
Modified: llvm/trunk/tools/llvm-cov/FunctionCoverageMapping.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/FunctionCoverageMapping.h?rev=217416&r1=217415&r2=217416&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/FunctionCoverageMapping.h (original)
+++ llvm/trunk/tools/llvm-cov/FunctionCoverageMapping.h Tue Sep 9 00:32:14 2014
@@ -22,21 +22,13 @@
namespace llvm {
-/// \brief Associates a source range with an execution count.
-struct MappingRegion : public coverage::CounterMappingRegion {
- uint64_t ExecutionCount;
-
- MappingRegion(const CounterMappingRegion &R, uint64_t ExecutionCount)
- : CounterMappingRegion(R), ExecutionCount(ExecutionCount) {}
-};
-
/// \brief Stores all the required information
/// about code coverage for a single function.
struct FunctionCoverageMapping {
/// \brief Raw function name.
std::string Name;
std::vector<std::string> Filenames;
- std::vector<MappingRegion> MappingRegions;
+ std::vector<coverage::CountedRegion> CountedRegions;
FunctionCoverageMapping(StringRef Name, ArrayRef<StringRef> Filenames)
: Name(Name), Filenames(Filenames.begin(), Filenames.end()) {}
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.cpp?rev=217416&r1=217415&r2=217416&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.cpp (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.cpp Tue Sep 9 00:32:14 2014
@@ -17,14 +17,13 @@
using namespace llvm;
using namespace coverage;
-void SourceCoverageDataManager::insert(const MappingRegion &Region) {
- SourceRange Range(Region.LineStart, Region.ColumnStart, Region.LineEnd,
- Region.ColumnEnd);
- if (Region.Kind == CounterMappingRegion::SkippedRegion) {
+void SourceCoverageDataManager::insert(const CountedRegion &CR) {
+ SourceRange Range(CR.LineStart, CR.ColumnStart, CR.LineEnd, CR.ColumnEnd);
+ if (CR.Kind == CounterMappingRegion::SkippedRegion) {
SkippedRegions.push_back(Range);
return;
}
- Regions.push_back(std::make_pair(Range, Region.ExecutionCount));
+ Regions.push_back(std::make_pair(Range, CR.ExecutionCount));
}
ArrayRef<std::pair<SourceCoverageDataManager::SourceRange, uint64_t>>
Modified: llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.h?rev=217416&r1=217415&r2=217416&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.h (original)
+++ llvm/trunk/tools/llvm-cov/SourceCoverageDataManager.h Tue Sep 9 00:32:14 2014
@@ -64,7 +64,7 @@ protected:
public:
SourceCoverageDataManager() : Uniqued(false) {}
- void insert(const MappingRegion &Region);
+ void insert(const coverage::CountedRegion &CR);
/// \brief Return the source ranges and execution counts
/// obtained from the non-skipped mapping regions.
More information about the llvm-commits
mailing list