aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/CoverageMappingTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ProfileData/CoverageMappingTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/CoverageMappingTest.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
index cbe9c1e..44b7a13 100644
--- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -129,6 +129,7 @@ struct InputFunctionCoverageData {
struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
bool UseMultipleReaders;
StringMap<unsigned> Files;
+ std::vector<std::string> Filenames;
std::vector<InputFunctionCoverageData> InputFunctions;
std::vector<OutputFunctionCoverageData> OutputFunctions;
@@ -146,7 +147,7 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
auto R = Files.find(Name);
if (R != Files.end())
return R->second;
- unsigned Index = Files.size();
+ unsigned Index = Files.size() + 1;
Files.try_emplace(Name, Index);
return Index;
}
@@ -200,11 +201,12 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
void readCoverageRegions(const std::string &Coverage,
OutputFunctionCoverageData &Data) {
- SmallVector<StringRef, 8> Filenames(Files.size());
+ Filenames.resize(Files.size() + 1);
for (const auto &E : Files)
- Filenames[E.getValue()] = E.getKey();
+ Filenames[E.getValue()] = E.getKey().str();
std::vector<CounterExpression> Expressions;
- RawCoverageMappingReader Reader(Coverage, Filenames, Data.Filenames,
+ ArrayRef<std::string> FilenameRefs = llvm::makeArrayRef(Filenames);
+ RawCoverageMappingReader Reader(Coverage, FilenameRefs, Data.Filenames,
Expressions, Data.Regions);
EXPECT_THAT_ERROR(Reader.read(), Succeeded());
}
@@ -895,7 +897,7 @@ INSTANTIATE_TEST_CASE_P(ParameterizedCovMapTest, CoverageMappingTest,
std::pair<bool, bool>({true, true})),);
TEST(CoverageMappingTest, filename_roundtrip) {
- std::vector<StringRef> Paths({"a", "b", "c", "d", "e"});
+ std::vector<std::string> Paths({"", "a", "b", "c", "d", "e"});
for (bool Compress : {false, true}) {
std::string EncodedFilenames;
@@ -905,16 +907,12 @@ TEST(CoverageMappingTest, filename_roundtrip) {
Writer.write(OS, Compress);
}
- std::vector<StringRef> ReadFilenames;
+ std::vector<std::string> ReadFilenames;
RawCoverageFilenamesReader Reader(EncodedFilenames, ReadFilenames);
- BinaryCoverageReader::DecompressedData Decompressed;
- EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion, Decompressed),
- Succeeded());
- if (!Compress)
- ASSERT_EQ(Decompressed.size(), 0U);
+ EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion), Succeeded());
ASSERT_EQ(ReadFilenames.size(), Paths.size());
- for (unsigned I = 0; I < Paths.size(); ++I)
+ for (unsigned I = 1; I < Paths.size(); ++I)
ASSERT_TRUE(ReadFilenames[I] == Paths[I]);
}
}