cbe: fix pointers to aliases of extern values
This commit is contained in:
committed by
Andrew Kelley
parent
11695745e5
commit
70c71935c7
@@ -888,15 +888,19 @@ pub const Decl = struct {
|
||||
assert(decl.dependencies.swapRemove(other));
|
||||
}
|
||||
|
||||
pub fn isExtern(decl: Decl, mod: *Module) bool {
|
||||
pub fn getExternDecl(decl: Decl, mod: *Module) OptionalIndex {
|
||||
assert(decl.has_tv);
|
||||
return switch (mod.intern_pool.indexToKey(decl.val.toIntern())) {
|
||||
.variable => |variable| variable.is_extern,
|
||||
.extern_func => true,
|
||||
else => false,
|
||||
.variable => |variable| if (variable.is_extern) variable.decl.toOptional() else .none,
|
||||
.extern_func => |extern_func| extern_func.decl.toOptional(),
|
||||
else => .none,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn isExtern(decl: Decl, mod: *Module) bool {
|
||||
return decl.getExternDecl(mod) != .none;
|
||||
}
|
||||
|
||||
pub fn getAlignment(decl: Decl, mod: *Module) u32 {
|
||||
assert(decl.has_tv);
|
||||
return @as(u32, @intCast(decl.alignment.toByteUnitsOptional() orelse decl.ty.abiAlignment(mod)));
|
||||
|
||||
@@ -1846,8 +1846,8 @@ pub const DeclGen = struct {
|
||||
|
||||
if (mod.decl_exports.get(decl_index)) |exports| {
|
||||
try writer.print("{}", .{exports.items[export_index].opts.name.fmt(&mod.intern_pool)});
|
||||
} else if (decl.isExtern(mod)) {
|
||||
try writer.print("{}", .{decl.name.fmt(&mod.intern_pool)});
|
||||
} else if (decl.getExternDecl(mod).unwrap()) |extern_decl_index| {
|
||||
try writer.print("{}", .{mod.declPtr(extern_decl_index).name.fmt(&mod.intern_pool)});
|
||||
} else {
|
||||
// MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case),
|
||||
// expand to 3x the length of its input, but let's cut it off at a much shorter limit.
|
||||
|
||||
Reference in New Issue
Block a user