# LLVM backends: work around poorly designed C API · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/44f833129c81bfa7117743fc7d54c44db09cc240)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 44f833129c81bfa7117743fc7d54c44db09cc240

Requested commit: 44f833129c81bfa7117743fc7d54c44db09cc240

Commit: 44f833129c81bfa7117743fc7d54c44db09cc240

Tree: 12f9d4dcf288019db49293c55935edca7e9262ab

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
LLVM backends: work around poorly designed C API

As part of the Opaque Pointers upgrade documentation, LLVM says that the
function LLVMGetGEPSourceElementType() can be used to obtain element
type information in lieu of LLVMGetElementType(), however, this function
actually returns the struct type, not the field type. The GEP
instruction does store the information we need, however, this is not
exposed in the C API. It seems like they accidentally exposed the wrong
field, because one would never need the struct type since one must
already pass it directly to the GEP instruction, so one will always have
it handy, whereas one will usually not have the field type handy.

```

## Parents

- [9e4091200e165db808216ad2a340c6ed4f18c494](https://git.cafe/gitcafe/zig/commit/9e4091200e165db808216ad2a340c6ed4f18c494?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/44f833129c81bfa7117743fc7d54c44db09cc240?format=markdown)
