llvm: Fix debug gen for 0-bit types
Add a regression test for that, since these weirdly never occur in any of the other tests on x86-64-linux.
This commit is contained in:
@@ -1950,7 +1950,6 @@ pub const Object = struct {
|
||||
},
|
||||
.Int => {
|
||||
const info = ty.intInfo(zcu);
|
||||
assert(info.bits != 0);
|
||||
const int_name = try o.allocTypeName(ty);
|
||||
defer gpa.free(int_name);
|
||||
const builder_name = try o.builder.metadataString(int_name);
|
||||
@@ -2132,7 +2131,6 @@ pub const Object = struct {
|
||||
const debug_elem_type = switch (elem_ty.zigTypeTag(zcu)) {
|
||||
.Int => blk: {
|
||||
const info = elem_ty.intInfo(zcu);
|
||||
assert(info.bits != 0);
|
||||
const vec_name = try o.allocTypeName(ty);
|
||||
defer gpa.free(vec_name);
|
||||
const builder_name = try o.builder.metadataString(vec_name);
|
||||
@@ -2446,8 +2444,6 @@ pub const Object = struct {
|
||||
if (decl.kind != .named) continue;
|
||||
if (decl.analysis != .complete) continue;
|
||||
|
||||
const decl_line = decl.typeSrcLine(zcu) + 1;
|
||||
|
||||
if (decl.val.typeOf(zcu).ip_index == .type_type) {
|
||||
const nested_type = decl.val.toType();
|
||||
// If this decl is the owner of the type, it will
|
||||
@@ -2457,11 +2453,20 @@ pub const Object = struct {
|
||||
if (owner == decl_id) continue;
|
||||
}
|
||||
|
||||
switch (nested_type.zigTypeTag(zcu)) {
|
||||
// We still may want these for a Zig expression
|
||||
// evaluator in debuggers, but for now they are
|
||||
// completely useless.
|
||||
.ComptimeInt, .ComptimeFloat,
|
||||
.Type, .Undefined, .Null, .EnumLiteral => continue,
|
||||
else => {},
|
||||
}
|
||||
|
||||
fields.appendAssumeCapacity(try o.builder.debugTypedef(
|
||||
try o.builder.metadataString(decl_name),
|
||||
try o.getDebugFile(namespace.fileScope(zcu)),
|
||||
fwd_ref,
|
||||
decl_line,
|
||||
0,
|
||||
try o.lowerDebugType(nested_type, false),
|
||||
0, // Align
|
||||
));
|
||||
@@ -2470,7 +2475,7 @@ pub const Object = struct {
|
||||
try o.builder.metadataString(decl_name),
|
||||
try o.getDebugFile(namespace.fileScope(zcu)),
|
||||
fwd_ref,
|
||||
decl_line,
|
||||
0,
|
||||
try o.lowerDebugType(Type.fromInterned(v.ty), false),
|
||||
));
|
||||
}
|
||||
|
||||
23
test/cases/llvm/debug_types.zig
Normal file
23
test/cases/llvm/debug_types.zig
Normal file
@@ -0,0 +1,23 @@
|
||||
const Ty = struct {
|
||||
pub const A = void;
|
||||
pub const B = @Vector(2, u0);
|
||||
pub const C = u0;
|
||||
pub const D = enum (u0) {};
|
||||
pub const E = type;
|
||||
pub const F = 1;
|
||||
pub const G = 1.0;
|
||||
pub const H = undefined;
|
||||
pub const I = null;
|
||||
pub const J = .foo;
|
||||
};
|
||||
pub fn main() void {
|
||||
inline for (@typeInfo(Ty).Struct.decls) |d|{
|
||||
_ = @field(Ty, d.name);
|
||||
}
|
||||
}
|
||||
|
||||
// compile
|
||||
// output_mode=Exe
|
||||
// backend=llvm
|
||||
// target=x86_64-linux,x86_64-macos
|
||||
//
|
||||
Reference in New Issue
Block a user