File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -3869,6 +3869,14 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration(
3869
3869
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::LineTables)
3870
3870
return ;
3871
3871
3872
+ // If this global variable contains an opaque type, replace it with its
3873
+ // underlying type.
3874
+ if (auto UnderlyingType = IGM.substOpaqueTypesWithUnderlyingTypes (
3875
+ DbgTy.getType ()->getCanonicalType ())) {
3876
+ auto &TI = IGM.getTypeInfoForUnlowered (UnderlyingType);
3877
+ DbgTy = DebugTypeInfo::getFromTypeInfo (UnderlyingType, TI, IGM);
3878
+ }
3879
+
3872
3880
llvm::DIType *DITy = getOrCreateType (DbgTy);
3873
3881
VarDecl *VD = nullptr ;
3874
3882
if (Loc)
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -primary-file %s -emit-ir -g -o - | %FileCheck %s
2
+
3
+ public protocol TheProtocol { }
4
+
5
+ public class TheClass : TheProtocol {
6
+ }
7
+
8
+ struct TheStruct < T> {
9
+ let t : T
10
+ }
11
+
12
+ func f( ) -> some TheProtocol {
13
+ let p : some TheProtocol = TheClass ( )
14
+ return p
15
+ }
16
+
17
+ let v = f ( )
18
+ // CHECK: !DIGlobalVariable(name: "v", {{.*}}type: ![[CONST_TYPE:[0-9]+]]
19
+ // CHECK: ![[CONST_TYPE]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[TYPE:[0-9]+]])
20
+ // CHECK: ![[TYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "TheClass"
21
+
22
+ let v2 = TheStruct ( t: f ( ) )
23
+ // CHECK: !DIGlobalVariable(name: "v2", {{.*}}type: ![[CONST_TYPE_GEN:[0-9]+]]
24
+ // CHECK: ![[CONST_TYPE_GEN]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[TYPE_GEN_1:[0-9]+]])
25
+ // CHECK: ![[TYPE_GEN_1]] = !DICompositeType(tag: DW_TAG_structure_type{{.*}}elements: ![[TYPE_GEN_2:[0-9]+]]
26
+ // CHECK: ![[TYPE_GEN_2]] = !{![[TYPE_GEN_3:[0-9]+]]}
27
+ // CHECK: ![[TYPE_GEN_3]] = !DIDerivedType(tag: DW_TAG_member{{.*}}baseType: ![[TYPE_GEN:[0-9]+]]
28
+ // CHECK: ![[TYPE_GEN]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$s17global_opaque_var9TheStructVyAA0D5ClassCGD"
You can’t perform that action at this time.
0 commit comments