diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-10-15 16:49:59 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-10-21 21:38:41 -0400 |
| commit | ecfb18286a5270943382effdf383bae4546b184f (patch) | |
| tree | a0f2853e50a26ab2d7e98f92cde006ac66de022a /src/Sema.zig | |
| parent | 3cd3052d4d303dbae7d517fa40f6d171c957afdd (diff) | |
| download | zig-ecfb18286a5270943382effdf383bae4546b184f.tar.gz zig-ecfb18286a5270943382effdf383bae4546b184f.zip | |
migrate make_ptr_const to new anonymous decl mechanism
Instead of creating Module.Decl objects, directly create InternPool
pointer values using the anon_decl Addr encoding.
The LLVM backend needed code to notice the alignment of the pointer and
lower accordingly. The other backends likely need a similar change.
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 2f861a87e6..3e8eeeb886 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -3657,9 +3657,10 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro const elem_ty = ptr_info.child.toType(); if (try sema.resolveComptimeKnownAllocValue(block, alloc, null)) |val| { - var anon_decl = try block.startAnonDecl(); - defer anon_decl.deinit(); - const new_mut_ptr = try sema.analyzeDeclRef(try anon_decl.finish(elem_ty, val.toValue(), ptr_info.flags.alignment)); + const new_mut_ptr = Air.internedToRef((try mod.intern(.{ .ptr = .{ + .ty = alloc_ty.toIntern(), + .addr = .{ .anon_decl = val }, + } }))); return sema.makePtrConst(block, new_mut_ptr); } |
