aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorCody Tapscott <topolarity@tapscott.me>2022-03-11 14:18:23 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-14 21:42:42 -0700
commit34a6fcd88e20a2491bf6a5396d583a7449cac20b (patch)
tree02eba522b43876b9145d8369332557d47d3f25c5 /src/Module.zig
parentbbd750ff05895f29be646bf51e8932c3c9fb14f3 (diff)
downloadzig-34a6fcd88e20a2491bf6a5396d583a7449cac20b.tar.gz
zig-34a6fcd88e20a2491bf6a5396d583a7449cac20b.zip
stage2: Add hasWellDefinedLayout() to type.zig and Sema.zig
This follows the same strategy as sema.typeRequiresComptime() and type.comptimeOnly(): Two versions of the function, one which performs resolution just-in-time and another which asserts that resolution is complete. Thankfully, this doesn't cause very viral type resolution, since auto-layout structs and unions are very common and are known to not have a well-defined layout without resolving their fields.
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Module.zig b/src/Module.zig
index b6104df232..7c6c654660 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -852,7 +852,7 @@ pub const ErrorSet = struct {
}
};
-pub const RequiresComptime = enum { no, yes, unknown, wip };
+pub const PropertyBoolean = enum { no, yes, unknown, wip };
/// Represents the data that a struct declaration provides.
pub const Struct = struct {
@@ -884,7 +884,8 @@ pub const Struct = struct {
/// If false, resolving the fields is necessary to determine whether the type has only
/// one possible value.
known_non_opv: bool,
- requires_comptime: RequiresComptime = .unknown,
+ requires_comptime: PropertyBoolean = .unknown,
+ has_well_defined_layout: PropertyBoolean = .unknown,
pub const Fields = std.StringArrayHashMapUnmanaged(Field);
@@ -1079,6 +1080,8 @@ pub const EnumFull = struct {
/// An integer type which is used for the numerical value of the enum.
/// Whether zig chooses this type or the user specifies it, it is stored here.
tag_ty: Type,
+ /// true if zig inferred this tag type, false if user specified it
+ tag_ty_inferred: bool,
/// Set of field names in declaration order.
fields: NameMap,
/// Maps integer tag value to field index.
@@ -1132,7 +1135,8 @@ pub const Union = struct {
// which `have_layout` does not ensure.
fully_resolved,
},
- requires_comptime: RequiresComptime = .unknown,
+ requires_comptime: PropertyBoolean = .unknown,
+ has_well_defined_layout: PropertyBoolean = .unknown,
pub const Field = struct {
/// undefined until `status` is `have_field_types` or `have_layout`.