[cxx-interop][SwiftCompilerSources] Fix conversion between std::string and Swift.String

This fixes a dangling pointer issue when creating a `Swift.String` from `std::string`.

Also fixes a warning:
```
warning: variable 's' was never mutated; consider changing to 'let' constant
    var s = SILBasicBlock_debugDescription(bridged)
    ~~~ ^
    let
```

rdar://92963081
rdar://93053488
This commit is contained in:
Egor Zhdan
2022-05-30 12:14:38 +01:00
parent 88ce7abbb5
commit be711e387f
9 changed files with 14 additions and 21 deletions

View File

@@ -38,8 +38,7 @@ public class Instruction : ListNode, CustomStringConvertible, Hashable {
final public var function: Function { block.function }
final public var description: String {
var s = SILNode_debugDescription(bridgedNode)
return String(cString: s.c_str())
String(_cxxString: SILNode_debugDescription(bridgedNode))
}
final public var operands: OperandArray {
@@ -143,8 +142,7 @@ public class SingleValueInstruction : Instruction, Value {
public final class MultipleValueInstructionResult : Value {
final public var description: String {
var s = SILNode_debugDescription(bridgedNode)
return String(cString: s.c_str())
String(_cxxString: SILNode_debugDescription(bridgedNode))
}
public var instruction: Instruction {