aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/CodeCoverage.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 20:23:46 +0100
committerBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 23:25:25 +0100
commitadcd02683856c30ba6f349279509acecd90063df (patch)
tree7b5927ef2ecab1618842183fac5ebe848f5832dd /llvm/tools/llvm-cov/CodeCoverage.cpp
parent5eaf44f99f0a0a3bdfa892892b8aaca841c8dbe0 (diff)
downloadllvm-adcd02683856c30ba6f349279509acecd90063df.zip
llvm-adcd02683856c30ba6f349279509acecd90063df.tar.gz
llvm-adcd02683856c30ba6f349279509acecd90063df.tar.bz2
Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index 5f1e23f2..4444fe6 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -413,7 +413,8 @@ void CodeCoverageTool::remapPathNames(const CoverageMapping &Coverage) {
// Convert input files from local paths to coverage data file paths.
StringMap<std::string> InvRemappedFilenames;
for (const auto &RemappedFilename : RemappedFilenames)
- InvRemappedFilenames[RemappedFilename.getValue()] = RemappedFilename.getKey();
+ InvRemappedFilenames[RemappedFilename.getValue()] =
+ std::string(RemappedFilename.getKey());
for (std::string &Filename : SourceFiles) {
SmallString<128> NativeFilename;
@@ -510,7 +511,7 @@ void CodeCoverageTool::demangleSymbols(const CoverageMapping &Coverage) {
for (const auto &Function : Coverage.getCoveredFunctions())
// On Windows, lines in the demangler's output file end with "\r\n".
// Splitting by '\n' keeps '\r's, so cut them now.
- DC.DemangledNames[Function.Name] = Symbols[I++].rtrim();
+ DC.DemangledNames[Function.Name] = std::string(Symbols[I++].rtrim());
}
void CodeCoverageTool::writeSourceFileView(StringRef SourceFile,
@@ -688,7 +689,8 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
// PathRemapping.
auto EquivPair = StringRef(PathRemap).split(',');
if (!(EquivPair.first.empty() && EquivPair.second.empty()))
- PathRemapping = EquivPair;
+ PathRemapping = {std::string(EquivPair.first),
+ std::string(EquivPair.second)};
// If a demangler is supplied, check if it exists and register it.
if (!DemanglerOpts.empty()) {
@@ -886,7 +888,7 @@ int CodeCoverageTool::doShow(int argc, const char **argv,
// Get the source files from the function coverage mapping.
for (StringRef Filename : Coverage->getUniqueSourceFiles()) {
if (!IgnoreFilenameFilters.matchesFilename(Filename))
- SourceFiles.push_back(Filename);
+ SourceFiles.push_back(std::string(Filename));
}
// Create an index out of the source files.