Skip to content

Commit a03b8ee

Browse files
committed
AST: Allow mangling LocatableType in DWARF mode
Fixes rdar://problem/145954323.
1 parent d98d6fd commit a03b8ee

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

lib/AST/ASTMangler.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,12 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
13791379
case TypeKind::BuiltinUnsafeValueBuffer:
13801380
return appendOperator("BB");
13811381
case TypeKind::BuiltinUnboundGeneric:
1382-
case TypeKind::Locatable:
1383-
llvm_unreachable("not a real type");
1382+
llvm::errs() << "Don't know how to mangle a BuiltinUnboundGenericType\n";
1383+
abort();
1384+
case TypeKind::Locatable: {
1385+
auto loc = cast<LocatableType>(tybase);
1386+
return appendType(loc->getSinglyDesugaredType(), sig, forDecl);
1387+
}
13841388
case TypeKind::BuiltinFixedArray: {
13851389
auto bfa = cast<BuiltinFixedArrayType>(tybase);
13861390
appendType(bfa->getSize(), sig, forDecl);
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@resultBuilder
2+
public struct Builder {
3+
@_alwaysEmitIntoClient
4+
public static func buildExpression<X>(_ x: X) -> X {x}
5+
@_alwaysEmitIntoClient
6+
public static func buildBlock<X>(_ x: X) -> X {x}
7+
}
8+
9+
public struct View<X> {
10+
public init(@Builder _: () -> X) {}
11+
12+
public func closure(_: () -> Void) {}
13+
}

test/DebugInfo/locatable_type.swift

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend %S/Inputs/result_builder.swift -emit-module -emit-module-path %t/result_builder.swiftmodule
3+
// RUN: %target-swift-frontend -emit-ir %s -I %t -g -O
4+
5+
// FIXME: Devise a test case that does not involve -O.
6+
7+
import result_builder
8+
9+
struct S {
10+
static func foo(_ s: S?) -> S? {s}
11+
static func foo(_ s: S) -> S {s}
12+
}
13+
14+
public func test() {
15+
View { View { S() } }
16+
.closure {
17+
let _: S? = .foo(S())
18+
}
19+
}

0 commit comments

Comments
 (0)