mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Sema: register correct dependencies for inline calls
And add a corresponding test case.
This commit is contained in:
parent
2fb78430db
commit
a99ad52b36
@ -7598,6 +7598,9 @@ fn analyzeCall(
|
|||||||
|
|
||||||
const module_fn = zcu.funcInfo(module_fn_index);
|
const module_fn = zcu.funcInfo(module_fn_index);
|
||||||
|
|
||||||
|
// The call site definitely depends on the function's signature.
|
||||||
|
try sema.declareDependency(.{ .src_hash = module_fn.zir_body_inst });
|
||||||
|
|
||||||
// This is not a function instance, so the function's `Nav` has a
|
// This is not a function instance, so the function's `Nav` has a
|
||||||
// `Cau` -- we don't need to check `generic_owner`.
|
// `Cau` -- we don't need to check `generic_owner`.
|
||||||
const fn_nav = ip.getNav(module_fn.owner_nav);
|
const fn_nav = ip.getNav(module_fn.owner_nav);
|
||||||
@ -7755,6 +7758,10 @@ fn analyzeCall(
|
|||||||
break :res Air.internedToRef(memoized_call.result);
|
break :res Air.internedToRef(memoized_call.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since we're doing an inline call, we depend on the source code of the whole
|
||||||
|
// function declaration.
|
||||||
|
try sema.declareDependency(.{ .src_hash = fn_cau.zir_index });
|
||||||
|
|
||||||
new_fn_info.return_type = sema.fn_ret_ty.toIntern();
|
new_fn_info.return_type = sema.fn_ret_ty.toIntern();
|
||||||
if (!is_comptime_call and !block.is_typeof) {
|
if (!is_comptime_call and !block.is_typeof) {
|
||||||
const zir_tags = sema.code.instructions.items(.tag);
|
const zir_tags = sema.code.instructions.items(.tag);
|
||||||
|
|||||||
23
test/incremental/modify_inline_fn
Normal file
23
test/incremental/modify_inline_fn
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#target=x86_64-linux
|
||||||
|
#update=initial version
|
||||||
|
#file=main.zig
|
||||||
|
const std = @import("std");
|
||||||
|
pub fn main() !void {
|
||||||
|
const str = getStr();
|
||||||
|
try std.io.getStdOut().writeAll(str);
|
||||||
|
}
|
||||||
|
inline fn getStr() []const u8 {
|
||||||
|
return "foo\n";
|
||||||
|
}
|
||||||
|
#expect_stdout="foo\n"
|
||||||
|
#update=change the string
|
||||||
|
#file=main.zig
|
||||||
|
const std = @import("std");
|
||||||
|
pub fn main() !void {
|
||||||
|
const str = getStr();
|
||||||
|
try std.io.getStdOut().writeAll(str);
|
||||||
|
}
|
||||||
|
inline fn getStr() []const u8 {
|
||||||
|
return "bar\n";
|
||||||
|
}
|
||||||
|
#expect_stdout="bar\n"
|
||||||
Loading…
x
Reference in New Issue
Block a user