Skip to content

Commit

Permalink
Merge pull request #18 from apple/string-init
Browse files Browse the repository at this point in the history
[LLVM] Add `llvm::StringRef` -> `String` initializer
  • Loading branch information
egorzhdan authored Oct 19, 2022
2 parents a132e1c + 5484308 commit 46c67a9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/LLVM/LLVM_Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
@_exported import LLVM_Utils // Clang module

extension String {
public init(_ stringRef: llvm.StringRef) {
self.init(cxxString: stringRef.str())
}

public func withStringRef<Result>(_ body: (llvm.StringRef) -> Result) -> Result {
var str = self
return str.withUTF8 { buffer in
Expand Down

0 comments on commit 46c67a9

Please sign in to comment.