aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/CoverageSummaryInfo.h
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-08-02 23:35:25 +0000
committerVedant Kumar <vsk@apple.com>2017-08-02 23:35:25 +0000
commitdde19c5a7362a08d0dcb8b692dae89ac6999ff2d (patch)
tree5a673f7b60f71ec5df44e08c4fa8032daab3e63c /llvm/tools/llvm-cov/CoverageSummaryInfo.h
parent79554e450e184160084c9abe90fe865735890477 (diff)
downloadllvm-dde19c5a7362a08d0dcb8b692dae89ac6999ff2d.zip
llvm-dde19c5a7362a08d0dcb8b692dae89ac6999ff2d.tar.gz
llvm-dde19c5a7362a08d0dcb8b692dae89ac6999ff2d.tar.bz2
[Coverage] Add an API to retrive all instantiations of a function (NFC)
The CoverageMapping::getInstantiations() API retrieved all function records corresponding to functions with more than one instantiation (e.g template functions with multiple specializations). However, there was no simple way to determine *which* function a given record was an instantiation of. This was an oversight, since it's useful to aggregate coverage information over all instantiations of a function. llvm-cov works around this by building a mapping of source locations to instantiation sets, but this duplicates logic that libCoverage already has (see FunctionInstantiationSetCollector). This change adds a new API, CoverageMapping::getInstantiationGroups(), which returns a list of InstantiationGroups. A group contains records for each instantiation of some particular function, and also provides utilities to get the total execution count within the group, the source location of the common definition, etc. This lets removes some hacky logic in llvm-cov by reusing FunctionInstantiationSetCollector and makes the CoverageMapping API friendlier for other clients. llvm-svn: 309904
Diffstat (limited to 'llvm/tools/llvm-cov/CoverageSummaryInfo.h')
-rw-r--r--llvm/tools/llvm-cov/CoverageSummaryInfo.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/tools/llvm-cov/CoverageSummaryInfo.h b/llvm/tools/llvm-cov/CoverageSummaryInfo.h
index 680fc37..1603731 100644
--- a/llvm/tools/llvm-cov/CoverageSummaryInfo.h
+++ b/llvm/tools/llvm-cov/CoverageSummaryInfo.h
@@ -115,7 +115,7 @@ struct FunctionCoverageInfo {
/// \brief A summary of function's code coverage.
struct FunctionCoverageSummary {
- StringRef Name;
+ std::string Name;
uint64_t ExecutionCount;
RegionCoverageInfo RegionCoverage;
LineCoverageInfo LineCoverage;
@@ -134,9 +134,11 @@ struct FunctionCoverageSummary {
static FunctionCoverageSummary
get(const coverage::FunctionRecord &Function);
- /// \brief Update the summary with information from another instantiation
- /// of this function.
- void update(const FunctionCoverageSummary &Summary);
+ /// Compute the code coverage summary for an instantiation group \p Group,
+ /// given a list of summaries for each instantiation in \p Summaries.
+ static FunctionCoverageSummary
+ get(const coverage::InstantiationGroup &Group,
+ ArrayRef<FunctionCoverageSummary> Summaries);
};
/// \brief A summary of file's code coverage.