Skip to content

Commit 550a0ce

Browse files
authored
Merge pull request #68291 from compnerd/split-em-up
ASTGen: account for alternate path separators
2 parents 981a6d6 + a61e6e7 commit 550a0ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/ASTGen/Sources/ASTGen/SourceManager+MacroExpansionContext.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ extension String {
4343
/// Retrieve the base name of a string that represents a path, removing the
4444
/// directory.
4545
var basename: String {
46-
guard let lastSlash = lastIndex(of: "/") else {
46+
guard let lastSlash = lastIndex(where: {
47+
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) || os(Android) || os(Linux)
48+
["/"].contains($0)
49+
#else
50+
["/", "\\"].contains($0)
51+
#endif
52+
}) else {
4753
return self
4854
}
4955

0 commit comments

Comments
 (0)