[Basic] Move copyCString to Basic/StringExtras.

Also, use StringRef.copy() instead of copyString().
This commit is contained in:
Rintaro Ishizaki
2022-02-16 12:32:58 -08:00
parent 5ab84ae242
commit 7ef93b2a67
8 changed files with 41 additions and 50 deletions

View File

@@ -760,7 +760,7 @@ static StringRef getModuleName(const ValueDecl *VD,
static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
if (auto ClangNode = VD->getClangNode()) {
if (const auto *ClangMod = Importer->getClangOwningModule(ClangNode))
return copyString(Allocator, ClangMod->getFullModuleName());
return StringRef(ClangMod->getFullModuleName()).copy(Allocator);
return "";
}
@@ -824,7 +824,7 @@ struct DeclInfo {
static StringRef copyAndClearString(llvm::BumpPtrAllocator &Allocator,
SmallVectorImpl<char> &Str) {
auto Ref = copyString(Allocator, StringRef(Str.data(), Str.size()));
auto Ref = StringRef(Str.data(), Str.size()).copy(Allocator);
Str.clear();
return Ref;
}
@@ -998,7 +998,7 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
SmallVector<ParentInfo, 4> Parents;
for (auto &Component : PathComponents) {
SwiftLangSupport::printUSR(Component.VD, OS);
Parents.emplace_back(copyString(Allocator, Component.Title),
Parents.emplace_back(Component.Title.str().copy(Allocator),
Component.Kind,
copyAndClearString(Allocator, Buffer));
};
@@ -1009,7 +1009,7 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
SmallVector<ParentInfo, 4> FIParents;
for (auto &Component: FI.ParentContexts) {
SwiftLangSupport::printUSR(Component.VD, OS);
FIParents.emplace_back(copyString(Allocator, Component.Title),
FIParents.emplace_back(Component.Title.str().copy(Allocator),
Component.Kind,
copyAndClearString(Allocator, Buffer));
}