summaryrefslogtreecommitdiff
path: root/unittests/ProfileData
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
commita8dfa81a14129ecbed6ed759421ec5936bb684f3 (patch)
treeb4b1f57bb8f11cb425e410be519dfc2a8513e0d4 /unittests/ProfileData
parentf6b53455dfc6d257276e3f088d18fe7edb27c97d (diff)
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ProfileData')
-rw-r--r--unittests/ProfileData/CoverageMappingTest.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/unittests/ProfileData/CoverageMappingTest.cpp b/unittests/ProfileData/CoverageMappingTest.cpp
index 6588e753eab..7b3abf79d33 100644
--- a/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/unittests/ProfileData/CoverageMappingTest.cpp
@@ -548,9 +548,10 @@ TEST_P(CoverageMappingTest, dont_detect_false_instantiations) {
EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());
- std::vector<const FunctionRecord *> Instantiations =
- LoadedCoverage->getInstantiations("expanded");
- ASSERT_TRUE(Instantiations.empty());
+ std::vector<InstantiationGroup> InstantiationGroups =
+ LoadedCoverage->getInstantiationGroups("expanded");
+ for (const auto &Group : InstantiationGroups)
+ ASSERT_EQ(Group.size(), 1U);
}
TEST_P(CoverageMappingTest, load_coverage_for_expanded_file) {