[clang][bytecode] Check for block pointers in __builtin_strlen() (#187988)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index fa4eb20..5f8bfcc 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -357,6 +357,9 @@
if (!CheckLive(S, OpPC, StrPtr, AK_Read))
return false;
+ if (!StrPtr.isBlockPointer())
+ return false;
+
if (!CheckDummy(S, OpPC, StrPtr.block(), AK_Read))
return false;
diff --git a/clang/test/AST/ByteCode/builtins.c b/clang/test/AST/ByteCode/builtins.c
index 5630a36..2d19ccb 100644
--- a/clang/test/AST/ByteCode/builtins.c
+++ b/clang/test/AST/ByteCode/builtins.c
@@ -19,3 +19,6 @@
_Static_assert(__atomic_is_lock_free(4, (void*)2), ""); // both-error {{not an integral constant expression}}
+
+_Static_assert(__builtin_strlen((void*)0 + 1) == 2, ""); // both-error {{not an integral constant expression}} \
+ // both-note {{cannot perform pointer arithmetic on null pointer}}