Author: Timm Baeder Date: 2026-01-02T12:00:45+01:00 New Revision: da5845d0330eee8c2ef5a0f14476d4c2f82492d9
URL: https://github.com/llvm/llvm-project/commit/da5845d0330eee8c2ef5a0f14476d4c2f82492d9 DIFF: https://github.com/llvm/llvm-project/commit/da5845d0330eee8c2ef5a0f14476d4c2f82492d9.diff LOG: [clang][bytecode] Check builtin_memchr for non-block pointers earlier (#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 Added: Modified: clang/lib/AST/ByteCode/InterpBuiltin.cpp clang/test/AST/ByteCode/builtins.c Removed: ################################################################################ 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
