aboutsummaryrefslogtreecommitdiff
path: root/src/Type.zig
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2025-02-01 15:47:06 +0000
committerGitHub <noreply@github.com>2025-02-01 15:47:06 +0000
commitc225b780e3944014300555c3b45eaccd7bc7c8ae (patch)
tree4c36c2b86776a5c0116e7212bc31dd1f4bfe3f78 /src/Type.zig
parent58c00a829e8acf438b91e9f7e1729ce79be722fa (diff)
parent149031204c0c804a66571a751b259da95886640d (diff)
downloadzig-c225b780e3944014300555c3b45eaccd7bc7c8ae.tar.gz
zig-c225b780e3944014300555c3b45eaccd7bc7c8ae.zip
Merge pull request #22708 from mlugg/memcpy-alias-zero-bit
Sema: skip aliasing check and runtime operation for `@memcpy` of zero-bit type
Diffstat (limited to 'src/Type.zig')
-rw-r--r--src/Type.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Type.zig b/src/Type.zig
index e6fc9c7d6a..403caad668 100644
--- a/src/Type.zig
+++ b/src/Type.zig
@@ -452,6 +452,13 @@ pub fn hasRuntimeBitsIgnoreComptime(ty: Type, zcu: *const Zcu) bool {
return hasRuntimeBitsInner(ty, true, .eager, zcu, {}) catch unreachable;
}
+pub fn hasRuntimeBitsIgnoreComptimeSema(ty: Type, pt: Zcu.PerThread) SemaError!bool {
+ return hasRuntimeBitsInner(ty, true, .sema, pt.zcu, pt.tid) catch |err| switch (err) {
+ error.NeedLazy => unreachable, // this would require a resolve strat of lazy
+ else => |e| return e,
+ };
+}
+
/// true if and only if the type takes up space in memory at runtime.
/// There are two reasons a type will return false:
/// * the type is a comptime-only type. For example, the type `type` itself.