Skip to content

Commit 259d78a

Browse files
fredrissMForster
authored andcommitted
Adapt to llvm.org StringRef API change
1 parent 710799d commit 259d78a

File tree

99 files changed

+347
-328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+347
-328
lines changed

include/swift/ABI/TypeIdentity.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ class TypeImportInfo {
129129
value = value.drop_front(1);
130130

131131
switch (component) {
132-
#define case_setIfNonEmpty(FIELD) \
133-
case TypeImportComponent::FIELD: \
134-
check(!value.empty(), "incoming value of " #FIELD " was empty"); \
135-
check(FIELD.empty(), #FIELD " was already set"); \
136-
FIELD = value; \
137-
return true; \
138-
139-
case_setIfNonEmpty(ABIName)
140-
case_setIfNonEmpty(SymbolNamespace)
141-
case_setIfNonEmpty(RelatedEntityName)
132+
#define case_setIfNonEmpty(FIELD) \
133+
case TypeImportComponent::FIELD: \
134+
check(!value.empty(), "incoming value of " #FIELD " was empty"); \
135+
check(FIELD.empty(), #FIELD " was already set"); \
136+
FIELD = StringType(value); \
137+
return true;
138+
139+
case_setIfNonEmpty(ABIName)
140+
case_setIfNonEmpty(SymbolNamespace)
141+
case_setIfNonEmpty(RelatedEntityName)
142142

143143
#undef case_setIfNonEmpty
144144
#undef check

include/swift/AST/Identifier.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class Identifier {
8383
const char *get() const { return Pointer; }
8484

8585
StringRef str() const { return Pointer; }
86-
86+
87+
explicit operator std::string() const { return std::string(Pointer); }
88+
8789
unsigned getLength() const {
8890
assert(Pointer != nullptr && "Tried getting length of empty identifier");
8991
return ::strlen(Pointer);

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ namespace swift {
369369
/// compiler flag.
370370
void addCustomConditionalCompilationFlag(StringRef Name) {
371371
assert(!Name.empty());
372-
CustomConditionalCompilationFlags.push_back(Name);
372+
CustomConditionalCompilationFlags.push_back(Name.str());
373373
}
374374

375375
/// Determines if a given conditional compilation flag has been set.

include/swift/Demangling/TypeDecoder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class TypeDecoder {
384384
}
385385
case NodeKind::BuiltinTypeName: {
386386
auto mangledName = Demangle::mangleNode(Node);
387-
return Builder.createBuiltinType(Node->getText(), mangledName);
387+
return Builder.createBuiltinType(Node->getText().str(), mangledName);
388388
}
389389
case NodeKind::Metatype:
390390
case NodeKind::ExistentialMetatype: {
@@ -683,12 +683,12 @@ class TypeDecoder {
683683
auto assocTypeChild = Node->getChild(1);
684684
auto member = assocTypeChild->getFirstChild()->getText();
685685
if (assocTypeChild->getNumChildren() < 2)
686-
return Builder.createDependentMemberType(member, base);
686+
return Builder.createDependentMemberType(member.str(), base);
687687

688688
auto protocol = decodeMangledProtocolType(assocTypeChild->getChild(1));
689689
if (!protocol)
690690
return BuiltType();
691-
return Builder.createDependentMemberType(member, base, protocol);
691+
return Builder.createDependentMemberType(member.str(), base, protocol);
692692
}
693693
case NodeKind::DependentAssociatedTypeRef: {
694694
if (Node->getNumChildren() < 2)

include/swift/Remote/MetadataReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ class MetadataReader {
823823

824824
#if SWIFT_OBJC_INTEROP
825825
BuiltProtocolDecl objcProtocol(StringRef name) {
826-
return builder.createObjCProtocolDecl(name);
826+
return builder.createObjCProtocolDecl(name.str());
827827
}
828828
#endif
829829
} resolver{Builder};

include/swift/SIL/SILFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ class SILFunction
683683
void addSemanticsAttr(StringRef Ref) {
684684
if (hasSemanticsAttr(Ref))
685685
return;
686-
SemanticsAttrSet.push_back(Ref);
686+
SemanticsAttrSet.push_back(Ref.str());
687687
std::sort(SemanticsAttrSet.begin(), SemanticsAttrSet.end());
688688
}
689689

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ void ASTContext::addSearchPath(StringRef searchPath, bool isFramework,
14471447
if (isFramework)
14481448
SearchPathOpts.FrameworkSearchPaths.push_back({searchPath, isSystem});
14491449
else
1450-
SearchPathOpts.ImportSearchPaths.push_back(searchPath);
1450+
SearchPathOpts.ImportSearchPaths.push_back(searchPath.str());
14511451

14521452
if (auto *clangLoader = getClangModuleLoader())
14531453
clangLoader->addSearchPath(searchPath, isFramework, isSystem);

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ std::string ASTPrinter::sanitizeUtf8(StringRef Text) {
272272
}
273273
Data += Step;
274274
}
275-
return Builder.str();
275+
return std::string(Builder);
276276
}
277277

278278
void ASTPrinter::anchor() {}
@@ -4543,7 +4543,7 @@ AnyFunctionType::getParamListAsString(ArrayRef<AnyFunctionType::Param> Params,
45434543
SmallString<16> Scratch;
45444544
llvm::raw_svector_ostream OS(Scratch);
45454545
AnyFunctionType::printParams(Params, OS);
4546-
return OS.str();
4546+
return std::string(OS.str());
45474547
}
45484548

45494549
void LayoutConstraintInfo::print(raw_ostream &OS,

lib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ void DiagnosticEngine::emitDiagnostic(const Diagnostic &diagnostic) {
989989
while (associatedNotes && *associatedNotes) {
990990
SmallString<128> notePath(getDiagnosticDocumentationPath());
991991
llvm::sys::path::append(notePath, *associatedNotes);
992-
educationalNotePaths.push_back(notePath.str());
992+
educationalNotePaths.push_back(notePath.str().str());
993993
associatedNotes++;
994994
}
995995
info->EducationalNotePaths = educationalNotePaths;

lib/AST/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2409,7 +2409,7 @@ StringRef ModuleEntity::getName() const {
24092409
std::string ModuleEntity::getFullName() const {
24102410
assert(!Mod.isNull());
24112411
if (auto SwiftMod = Mod.dyn_cast<const ModuleDecl*>())
2412-
return SwiftMod->getName().str();
2412+
return std::string(SwiftMod->getName());
24132413
return getClangModule(Mod)->getFullModuleName();
24142414
}
24152415

0 commit comments

Comments
 (0)