# sema: clean-up \`\{union,struct\}FieldAlignment\` and friends · gitcafe/zig

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

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

Visibility: public

Requested revision: 80cd53d3bbf5cdc82715a4400592b40fb93cd5c9

Requested commit: 80cd53d3bbf5cdc82715a4400592b40fb93cd5c9

Commit: 80cd53d3bbf5cdc82715a4400592b40fb93cd5c9

Tree: 5f12824c1173b4a2fc9cc78f39a0226419a18f54

Author: David Rubin

Committer: David Rubin

## Message

```
sema: clean-up `{union,struct}FieldAlignment` and friends

My main gripes with this design were that it was incorrectly namespaced, the naming was inconsistent and a bit wrong (`fooAlign` vs `fooAlignment`).

This commit moves all the logic from `PerThread.zig` to use the zcu + tid system that the previous couple commits introduce.
I've organized and merged the functions to be a bit more specific to their own purpose.

- `fieldAlignment` takes a struct or union type, an index, and a Zcu (or the Sema version which takes a Pt), and gives you the alignment of the field at the index.
- `structFieldAlignment` takes the field type itself, and provides the logic to handle special cases, such as externs.

A design goal I had in mind was to avoid using the word 'struct' in the function name, when it worked for things that aren't structs, such as unions.

```

## Parents

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

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