[llvm] [LLVM][Coverage][Unittest] Fix dangling reference in unittest (PR #147118)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 11 09:34:11 PDT 2025


================
@@ -233,13 +235,10 @@ struct CoverageMappingTest : ::testing::TestWithParam<std::tuple<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);
+    Data.FilenamesStorage.resize(Files.size() + 1);
----------------
ellishg wrote:

Why `+ 1`?

https://github.com/llvm/llvm-project/pull/147118


More information about the llvm-commits mailing list