diff options
author | Jordan Rose <jordan_rose@apple.com> | 2016-11-07 17:28:04 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2016-11-07 17:28:04 +0000 |
commit | b31ee819c8311b87010eda79ab0c9bd3244201e2 (patch) | |
tree | 06747a50d8273a6724d6b95e15196a414eea1668 /clang/lib/CodeGen/CoverageMappingGen.cpp | |
parent | da43a5e768a3f7ed08db91491d24c6f5e3db58f9 (diff) | |
download | bcm5719-llvm-b31ee819c8311b87010eda79ab0c9bd3244201e2.tar.gz bcm5719-llvm-b31ee819c8311b87010eda79ab0c9bd3244201e2.zip |
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.
llvm-svn: 286122
Diffstat (limited to 'clang/lib/CodeGen/CoverageMappingGen.cpp')
-rw-r--r-- | clang/lib/CodeGen/CoverageMappingGen.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index 530ac836112..5bc9e5011aa 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/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()) |