llir / llvm

Library for interacting with LLVM IR in pure Go.
https://llir.github.io/document/
BSD Zero Clause License
1.19k stars 78 forks source link

No way to find underlying type of pointer or array #237

Closed FlummoxTheMagnificent closed 7 months ago

FlummoxTheMagnificent commented 7 months ago

There are functions in types, IsPointer() and IsArray(), that return whether or not the provided type is a pointer or array, respectively. However, there is no way to know what the pointer is pointing to or what the array is storing, which makes working with them incredibly difficult. item.Type().(types.PointerType).ElemType and item.Type().(types.ArrayType).ElemType should work, but they don't, because the Go compiler won't allow the type assertion:

impossible type assertion: item.Type().(types.PointerType) types.PointerType does not implement types.Type (method Equal has pointer receiver)

Please fix this; it is incredibly difficult to create pointers and arrays currently.

FlummoxTheMagnificent commented 7 months ago

Can cast item to pointer, case the pointer to an array, and dereference again, which works for some reason?