Skip to content

Commit 4950a56

Browse files
committed
fix(smir): accept core drop glue names
1 parent ae3e60a commit 4950a56

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

kmir/src/kmir/smir.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
_LOGGER: Final = logging.getLogger(__name__)
2121
_LOG_FORMAT: Final = '%(levelname)s %(asctime)s %(name)s - %(message)s'
22+
_DROP_IN_PLACE_PREFIXES: Final = ('std::ptr::drop_in_place::<', 'core::ptr::drop_in_place::<')
2223

2324

2425
AdtDef = NewType('AdtDef', int)
@@ -185,7 +186,7 @@ def drop_function_tys(self) -> dict[Ty, Ty]:
185186
if mono_item is None:
186187
continue
187188

188-
if not mono_item['name'].startswith('std::ptr::drop_in_place::<'):
189+
if not mono_item['name'].startswith(_DROP_IN_PLACE_PREFIXES):
189190
continue
190191

191192
body = mono_item.get('body')

kmir/src/tests/unit/test_smir.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,47 @@ def test_call_edges_preserve_drop_glue_for_index_projection() -> None:
214214
)
215215

216216
assert smir_info.call_edges == {10: {12}, 12: set()}
217+
218+
219+
def test_drop_function_tys_accept_core_drop_in_place_names() -> None:
220+
smir_info = SMIRInfo(
221+
{
222+
'name': 'core-drop-glue',
223+
'allocs': [],
224+
'types': [
225+
[
226+
2,
227+
{
228+
'StructType': {
229+
'name': 'Inner',
230+
'adt_def': 2,
231+
'fields': [],
232+
'layout': None,
233+
}
234+
},
235+
],
236+
[3, {'PtrType': {'pointee_type': 2}}],
237+
],
238+
'functions': [
239+
[12, {'NormalSym': 'drop_inner'}],
240+
],
241+
'items': [
242+
{
243+
'symbol_name': 'drop_inner',
244+
'mono_item_kind': {
245+
'MonoItemFn': {
246+
'name': 'core::ptr::drop_in_place::<Inner>',
247+
'body': {
248+
'arg_count': 1,
249+
'locals': [{'ty': 0}, {'ty': 3}],
250+
'blocks': [],
251+
},
252+
}
253+
},
254+
},
255+
],
256+
'spans': [],
257+
}
258+
)
259+
260+
assert smir_info.drop_function_tys == {2: 12}

0 commit comments

Comments
 (0)