From 0c5b6020153341f7ec27e178b348f117c957eca8 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Tue, 8 May 2018 19:26:51 +0000 Subject: [Coverage] Take filenames into account when loading function records. Summary: Don't skip functions with the same name but from different files. That change makes it possible to generate code coverage reports from different binaries compiled from different sources even if there are functions with non-unique names. Without that change, code coverage for such functions is missing except of the first function processed. Reviewers: vsk, morehouse Reviewed By: vsk Subscribers: llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D46478 llvm-svn: 331801 --- llvm/unittests/ProfileData/CoverageMappingTest.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'llvm/unittests/ProfileData/CoverageMappingTest.cpp') diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp index 4d0f852..987f676 100644 --- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp +++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp @@ -859,17 +859,34 @@ TEST_P(CoverageMappingTest, load_coverage_for_expanded_file) { TEST_P(CoverageMappingTest, skip_duplicate_function_record) { ProfileWriter.addRecord({"func", 0x1234, {1}}, Err); + // This record should be loaded. startFunction("func", 0x1234); addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9); + // This record should be loaded. startFunction("func", 0x1234); addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9); + addCMR(Counter::getCounter(0), "file2", 1, 1, 9, 9); + + // This record should be skipped. + startFunction("func", 0x1234); + addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9); + + // This record should be loaded. + startFunction("func", 0x1234); + addCMR(Counter::getCounter(0), "file2", 1, 1, 9, 9); + addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9); + + // This record should be skipped. + startFunction("func", 0x1234); + addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9); + addCMR(Counter::getCounter(0), "file2", 1, 1, 9, 9); EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded()); auto Funcs = LoadedCoverage->getCoveredFunctions(); unsigned NumFuncs = std::distance(Funcs.begin(), Funcs.end()); - ASSERT_EQ(1U, NumFuncs); + ASSERT_EQ(3U, NumFuncs); } // FIXME: Use ::testing::Combine() when llvm updates its copy of googletest. -- cgit v1.1