Skip to content

Commit 5484308

Browse files
committed
[LLVM] Add llvm::StringRef -> String initializer
This allows conveniently getting a Swift String from an LLVM StringRef.
1 parent a132e1c commit 5484308

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/LLVM/LLVM_Utils.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
@_exported import LLVM_Utils // Clang module
1414

1515
extension String {
16+
public init(_ stringRef: llvm.StringRef) {
17+
self.init(cxxString: stringRef.str())
18+
}
19+
1620
public func withStringRef<Result>(_ body: (llvm.StringRef) -> Result) -> Result {
1721
var str = self
1822
return str.withUTF8 { buffer in

0 commit comments

Comments
 (0)