https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/174192
The getType() call might fail. We can't pull the isReadable() check up though because that creates different diagnostic output compared to the current interpreter. Fixes #172202 >From ce34cb698089977ed3ebfb7b7dd1e99380144b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Fri, 2 Jan 2026 10:56:31 +0100 Subject: [PATCH] [clang][bytecode] Check builtin_memchr for non-block pointers earlier The getType() call might fail. We can't pull the isReadable() check up though because that creates different diagnostic output compared to the current interpreter. Fixes #172202 --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 3 +++ clang/test/AST/ByteCode/builtins.c | 1 + 2 files changed, 4 insertions(+) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 065870c5c0ab5..b4acb786fa90c 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -2078,6 +2078,9 @@ static bool interp__builtin_memchr(InterpState &S, CodePtr OpPC, return false; } + if (!Ptr.isBlockPointer()) + return false; + QualType ElemTy = Ptr.getFieldDesc()->isArray() ? Ptr.getFieldDesc()->getElemQualType() : Ptr.getFieldDesc()->getType(); diff --git a/clang/test/AST/ByteCode/builtins.c b/clang/test/AST/ByteCode/builtins.c index 5be5455ab8813..684db52296fc2 100644 --- a/clang/test/AST/ByteCode/builtins.c +++ b/clang/test/AST/ByteCode/builtins.c @@ -18,3 +18,4 @@ int structStrlen(void) { } void f() { __builtin_memcpy(f, f, 1); } +void f2() { __builtin_memchr(f2, 0, 1); } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
