TheDan64 / inkwell

It's a New Kind of Wrapper for Exposing LLVM (Safely)
https://thedan64.github.io/inkwell/
Apache License 2.0
2.38k stars 229 forks source link

Restricting build_*_gep to make it safer. #467

Open JCBurnside opened 9 months ago

JCBurnside commented 9 months ago

Is your feature request related to a problem? Please describe. I have multiple times accidentally used build_*_gep with the wrong pointee type thinking it would the result type in llvm15+

Describe the solution you'd like Add a new trait potentially called IndexableType or GEPable that would restrict what types can be used in a gep instruction. it would be implemented on PointerType, VectorType, ArrayType, and StructType

Describe possible drawbacks to your solution potentially breaks backwards compat.

Describe alternatives you've considered paying more attention when writing gep instructions.

JCBurnside commented 9 months ago

Seems like a simple marker trait to help limit the unsafeness of the build gep calls.