aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2025-02-05 10:27:17 +0000
committergingerBill <bill@gingerbill.org>2025-02-05 10:27:17 +0000
commitf80bea5b1142c6b317f8f52bb9b3814afe5d3c1b (patch)
tree5682dc3cb23ac1a528deef0c8265866006411992 /src/types.cpp
parentab469e657dcd975bbce3b7b211326363ce17ac92 (diff)
Remove transmute suggestion with `-vet-cast` when transmuting native <-> endian-specific types
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp
index 0b6e6d334..412448cbc 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -1801,6 +1801,27 @@ gb_internal bool is_type_union_maybe_pointer_original_alignment(Type *t) {
}
+enum TypeEndianKind {
+ TypeEndian_Platform,
+ TypeEndian_Little,
+ TypeEndian_Big,
+};
+
+gb_internal TypeEndianKind type_endian_kind_of(Type *t) {
+ t = core_type(t);
+ if (t->kind == Type_Basic) {
+ if (t->Basic.flags & BasicFlag_EndianLittle) {
+ return TypeEndian_Little;
+ }
+ if (t->Basic.flags & BasicFlag_EndianBig) {
+ return TypeEndian_Big;
+ }
+ } else if (t->kind == Type_BitSet) {
+ return type_endian_kind_of(bit_set_to_int(t));
+ }
+ return TypeEndian_Platform;
+}
+
gb_internal bool is_type_endian_big(Type *t) {
t = core_type(t);