Skip to content

Commit fc73047

Browse files
authored
Merge pull request #59317 from apple/egorzhdan/revert-libswift-string-init
Revert "[cxx-interop][SwiftCompilerSources] Fix conversion between `std::string` and `Swift.String`"
2 parents fd2a8e7 + 9542837 commit fc73047

File tree

9 files changed

+21
-14
lines changed

9 files changed

+21
-14
lines changed

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import BasicBridging
14-
import std
1514

1615
//===----------------------------------------------------------------------===//
1716
// StringRef
@@ -61,13 +60,6 @@ extension String {
6160
return c(BridgedStringRef(data: buffer.baseAddress, length: buffer.count))
6261
}
6362
}
64-
65-
/// Underscored to avoid name collision with the std overlay.
66-
/// To be replaced with an overlay call once the CI uses SDKs built with Swift 5.8.
67-
public init(_cxxString s: std.string) {
68-
self.init(cString: s.c_str())
69-
withExtendedLifetime(s) {}
70-
}
7163
}
7264

7365
extension Array {

SwiftCompilerSources/Sources/SIL/BasicBlock.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ final public class BasicBlock : ListNode, CustomStringConvertible, HasShortDescr
2525
public var function: Function { SILBasicBlock_getFunction(bridged).function }
2626

2727
public var description: String {
28-
String(_cxxString: SILBasicBlock_debugDescription(bridged))
28+
var s = SILBasicBlock_debugDescription(bridged)
29+
return String(cString: s.c_str())
2930
}
3031
public var shortDescription: String { name }
3132

SwiftCompilerSources/Sources/SIL/Function.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ final public class Function : CustomStringConvertible, HasShortDescription {
2121
}
2222

2323
final public var description: String {
24-
String(_cxxString: SILFunction_debugDescription(bridged))
24+
var s = SILFunction_debugDescription(bridged)
25+
return String(cString: s.c_str())
2526
}
2627

2728
public var shortDescription: String { name.string }

SwiftCompilerSources/Sources/SIL/GlobalVariable.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ final public class GlobalVariable : CustomStringConvertible, HasShortDescription
1919
}
2020

2121
public var description: String {
22-
String(_cxxString: SILGlobalVariable_debugDescription(bridged))
22+
var s = SILGlobalVariable_debugDescription(bridged)
23+
return String(cString: s.c_str())
2324
}
2425

2526
public var shortDescription: String { name.string }

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public class Instruction : ListNode, CustomStringConvertible, Hashable {
3838
final public var function: Function { block.function }
3939

4040
final public var description: String {
41-
String(_cxxString: SILNode_debugDescription(bridgedNode))
41+
var s = SILNode_debugDescription(bridgedNode)
42+
return String(cString: s.c_str())
4243
}
4344

4445
final public var operands: OperandArray {
@@ -142,7 +143,8 @@ public class SingleValueInstruction : Instruction, Value {
142143

143144
public final class MultipleValueInstructionResult : Value {
144145
final public var description: String {
145-
String(_cxxString: SILNode_debugDescription(bridgedNode))
146+
var s = SILNode_debugDescription(bridgedNode)
147+
return String(cString: s.c_str())
146148
}
147149

148150
public var instruction: Instruction {

SwiftCompilerSources/Sources/SIL/Value.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public enum Ownership {
8181

8282
extension Value {
8383
public var description: String {
84-
String(_cxxString: SILNode_debugDescription(bridgedNode))
84+
var s = SILNode_debugDescription(bridgedNode)
85+
return String(cString: s.c_str())
8586
}
8687

8788
public var uses: UseList {

test/SILOptimizer/addr_escape_info.sil

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// REQUIRES: swift_in_compiler
44

5+
// rdar92963081
6+
// UNSUPPORTED: OS=linux-gnu
7+
58
sil_stage canonical
69

710
import Builtin

test/SILOptimizer/escape_info.sil

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// REQUIRES: swift_in_compiler
44

5+
// rdar92963081
6+
// UNSUPPORTED: OS=linux-gnu
7+
58

69
sil_stage canonical
710

test/SILOptimizer/ranges.sil

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
// REQUIRES: swift_in_compiler
44

5+
// rdar92963081
6+
// UNSUPPORTED: OS=linux-gnu
7+
58

69
sil_stage canonical
710

0 commit comments

Comments
 (0)