summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/CoverageMappingGen.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2016-11-07 17:28:04 +0000
committerJordan Rose <jordan_rose@apple.com>2016-11-07 17:28:04 +0000
commitf874c07d7169bc68a9dd312138598c3ccfc69c1d (patch)
tree5df20bb196b9ff929334f55779ef0f88ccb57728 /lib/CodeGen/CoverageMappingGen.cpp
parent8bfac0433024117c47adcc00755feb8d1adc4546 (diff)
Fix use-of-temporary with StringRef in code coverage
The fixed code is basically identical to the same loop below, which might indicate an opportunity for refactoring. I just wanted to fix the use-of-temporary issue. Caught by adding a similar check to StringRef as r283798 did for ArrayRef. I'll be upstreaming that soon. Reviewed by Vedant Kumar as https://reviews.llvm.org/D26317. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286122 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r--lib/CodeGen/CoverageMappingGen.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/CodeGen/CoverageMappingGen.cpp b/lib/CodeGen/CoverageMappingGen.cpp
index 530ac83611..5bc9e5011a 100644
--- a/lib/CodeGen/CoverageMappingGen.cpp
+++ b/lib/CodeGen/CoverageMappingGen.cpp
@@ -1039,10 +1039,15 @@ void CoverageMappingModuleGen::addFunctionMappingRecord(
std::vector<StringRef> Filenames;
std::vector<CounterExpression> Expressions;
std::vector<CounterMappingRegion> Regions;
+ llvm::SmallVector<std::string, 16> FilenameStrs;
llvm::SmallVector<StringRef, 16> FilenameRefs;
+ FilenameStrs.resize(FileEntries.size());
FilenameRefs.resize(FileEntries.size());
- for (const auto &Entry : FileEntries)
- FilenameRefs[Entry.second] = normalizeFilename(Entry.first->getName());
+ for (const auto &Entry : FileEntries) {
+ auto I = Entry.second;
+ FilenameStrs[I] = normalizeFilename(Entry.first->getName());
+ FilenameRefs[I] = FilenameStrs[I];
+ }
RawCoverageMappingReader Reader(CoverageMapping, FilenameRefs, Filenames,
Expressions, Regions);
if (Reader.read())