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.
diff --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp
index 525f770..e94a768 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -41,7 +41,7 @@
Inc.R = halfOpenToRange(SM, FilenameRange);
Inc.Written =
(IsAngled ? "<" + FileName + ">" : "\"" + FileName + "\"").str();
- Inc.Resolved = File ? File->tryGetRealPathName() : "";
+ Inc.Resolved = std::string(File ? File->tryGetRealPathName() : "");
Inc.HashOffset = SM.getFileOffset(HashLoc);
Inc.FileKind = FileKind;
}
@@ -120,7 +120,7 @@
llvm::StringRef IncludedRealName) {
auto Child = fileIndex(IncludedName);
if (!IncludedRealName.empty() && RealPathNames[Child].empty())
- RealPathNames[Child] = IncludedRealName;
+ RealPathNames[Child] = std::string(IncludedRealName);
auto Parent = fileIndex(IncludingName);
IncludeChildren[Parent].push_back(Child);
}