From ff6dc053b7ba8ffb7d02c9c4560fe80b66b117b8 Mon Sep 17 00:00:00 2001 From: Jinsong Ji Date: Wed, 24 Feb 2021 14:27:23 +0000 Subject: [PATCH] [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 --- llvm/unittests/ProfileData/CoverageMappingTest.cpp | 3 +++ 1 file changed, 3 insertions(+) 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> { 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(); -- 2.7.4