[clang] 5da7e9a - [clang][bytecode] Return Invalid() from atomic_is_lock_free calls (#179676)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 4 07:11:19 PST 2026
Author: Timm Baeder
Date: 2026-02-04T16:11:13+01:00
New Revision: 5da7e9a2ad89b73214c7478d52db4fd6e8068d95
URL: https://github.com/llvm/llvm-project/commit/5da7e9a2ad89b73214c7478d52db4fd6e8068d95
DIFF: https://github.com/llvm/llvm-project/commit/5da7e9a2ad89b73214c7478d52db4fd6e8068d95.diff
LOG: [clang][bytecode] Return Invalid() from atomic_is_lock_free calls (#179676)
If they are invalid. This is what the current interpreter does.
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 b7bd667288533..b5f0b0721eaed 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1125,7 +1125,7 @@ static bool interp__builtin_atomic_lock_free(InterpState &S, CodePtr OpPC,
if (BuiltinOp == Builtin::BI__atomic_always_lock_free)
return returnBool(false);
- return false;
+ return Invalid(S, OpPC);
}
/// bool __c11_atomic_is_lock_free(size_t)
diff --git a/clang/test/AST/ByteCode/builtins.c b/clang/test/AST/ByteCode/builtins.c
index 684db52296fc2..5630a36e1c05b 100644
--- a/clang/test/AST/ByteCode/builtins.c
+++ b/clang/test/AST/ByteCode/builtins.c
@@ -1,8 +1,5 @@
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter %s -verify
-// RUN: %clang_cc1 %s -verify=ref
-
-// expected-no-diagnostics
-// ref-no-diagnostics
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter %s -verify=expected,both
+// RUN: %clang_cc1 %s -verify=ref,both
extern __SIZE_TYPE__ strlen(const char *);
@@ -19,3 +16,6 @@ int structStrlen(void) {
void f() { __builtin_memcpy(f, f, 1); }
void f2() { __builtin_memchr(f2, 0, 1); }
+
+
+_Static_assert(__atomic_is_lock_free(4, (void*)2), ""); // both-error {{not an integral constant expression}}
More information about the cfe-commits
mailing list