aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/CoverageMappingTest.cpp
diff options
context:
space:
mode:
authorJinsong Ji <jji@us.ibm.com>2021-02-24 14:27:23 +0000
committerJinsong Ji <jji@us.ibm.com>2021-02-24 14:59:40 +0000
commitff6dc053b7ba8ffb7d02c9c4560fe80b66b117b8 (patch)
tree81fe2dbfef714fde9b5a88917f1aaaf0994fc5a1 /llvm/unittests/ProfileData/CoverageMappingTest.cpp
parent9ced8b3b614ceba7dcd4a8fc3d2fc0be7d09f650 (diff)
downloadllvm-ff6dc053b7ba8ffb7d02c9c4560fe80b66b117b8.zip
llvm-ff6dc053b7ba8ffb7d02c9c4560fe80b66b117b8.tar.gz
llvm-ff6dc053b7ba8ffb7d02c9c4560fe80b66b117b8.tar.bz2
[Coverage][Unittest] Fix stringref issue
We will pass StringRef and change it in reader. But we reuse the same Filename vector without clear it, so in some systems, we may clobbeer previous results. Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D97353
Diffstat (limited to 'llvm/unittests/ProfileData/CoverageMappingTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/CoverageMappingTest.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/CoverageMappingTest.cpp b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
index 44b7a13..d1bb87a 100644
--- a/llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ b/llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -201,6 +201,9 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::pair<bool, bool>> {
void readCoverageRegions(const std::string &Coverage,
OutputFunctionCoverageData &Data) {
+ // We will re-use the StringRef in duplicate tests, clear it to avoid
+ // clobber previous ones.
+ Filenames.clear();
Filenames.resize(Files.size() + 1);
for (const auto &E : Files)
Filenames[E.getValue()] = E.getKey().str();