@@ -45,3 +45,88 @@ def test_function_symbols_reverse(smir_file: Path, update_expected_output: bool)
4545def test_function_tys (smir_file : Path , update_expected_output : bool ) -> None :
4646 """Test function_tys using actual SMIR JSON data."""
4747 _test_smir_property (smir_file , 'function_tys' , update_expected_output )
48+
49+
50+ def test_call_edges_preserve_drop_glue_for_downcast_field () -> None :
51+ smir_info = SMIRInfo (
52+ {
53+ 'name' : 'drop-downcast-field' ,
54+ 'allocs' : [],
55+ 'types' : [
56+ [
57+ 1 ,
58+ {
59+ 'EnumType' : {
60+ 'name' : 'Wrapper' ,
61+ 'adt_def' : 1 ,
62+ 'discriminants' : [0 ],
63+ 'fields' : [[2 ]],
64+ 'layout' : None ,
65+ }
66+ },
67+ ],
68+ [
69+ 2 ,
70+ {
71+ 'StructType' : {
72+ 'name' : 'Inner' ,
73+ 'adt_def' : 2 ,
74+ 'fields' : [],
75+ 'layout' : None ,
76+ }
77+ },
78+ ],
79+ [3 , {'PtrType' : {'pointee_type' : 2 }}],
80+ ],
81+ 'functions' : [
82+ [10 , {'NormalSym' : 'caller' }],
83+ [12 , {'NormalSym' : 'drop_inner' }],
84+ ],
85+ 'items' : [
86+ {
87+ 'symbol_name' : 'caller' ,
88+ 'mono_item_kind' : {
89+ 'MonoItemFn' : {
90+ 'name' : 'caller' ,
91+ 'body' : {
92+ 'arg_count' : 0 ,
93+ 'locals' : [{'ty' : 0 }, {'ty' : 1 }],
94+ 'blocks' : [
95+ {
96+ 'terminator' : {
97+ 'kind' : {
98+ 'Drop' : {
99+ 'place' : {
100+ 'local' : 1 ,
101+ 'projection' : [{'Downcast' : 0 }, {'Field' : [0 , 2 ]}],
102+ },
103+ 'target' : 0 ,
104+ 'unwind' : 'Continue' ,
105+ }
106+ }
107+ }
108+ }
109+ ],
110+ },
111+ }
112+ },
113+ },
114+ {
115+ 'symbol_name' : 'drop_inner' ,
116+ 'mono_item_kind' : {
117+ 'MonoItemFn' : {
118+ 'name' : 'std::ptr::drop_in_place::<Inner>' ,
119+ 'body' : {
120+ 'arg_count' : 1 ,
121+ 'locals' : [{'ty' : 0 }, {'ty' : 3 }],
122+ 'blocks' : [],
123+ },
124+ }
125+ },
126+ },
127+ ],
128+ 'spans' : [],
129+ }
130+ )
131+
132+ assert smir_info .call_edges == {10 : {12 }, 12 : set ()}
0 commit comments