arocc icon indicating copy to clipboard operation
arocc copied to clipboard

Type: add helpers for managing typeof and attributed types

Open ehaas opened this issue 1 year ago • 3 comments

The idea behind this is to prepare for #733 by making typeof and attributed types slightly less annoying to deal with, by moving the recursive call logic to a single place (2 actually), which should make it easier to add a new typedef specifier which will generally just call into its subtype for most of the Type functions.

ehaas avatar Aug 21 '24 23:08 ehaas

Wouldn't something more like canonicalize be better? This strategy already requires a duplicate function with a one arg difference.

Maybe a Type.base() which would use a while loop instead of recursion. Most places that use canonicalize seem like they actually want that kind of functionality.

Vexu avatar Aug 22 '24 15:08 Vexu

Is the idea that each function that currently recurses on typeof/attributed types, should instead call canonicalize/base on its argument first? I think that would also work and yeah probably simpler.

ehaas avatar Aug 22 '24 18:08 ehaas

Something like that yes. It would also work well if in the future Type is reworked to be interned or something similar.

Vexu avatar Aug 23 '24 09:08 Vexu

This branch has a fairly heavy performance hit (~5% for large files), and even with just Type.base replacing canonicalize where we only want the specifier, it's still about 1.5% slower. So now I'm kinda leaning toward, we just implement typedef specifiers in the code as-is, and then hopefully clean everything up with Type interning in the future.

ehaas avatar Aug 24 '24 16:08 ehaas