[clang] 8fae5a5 - [clang][bytecode] Check builtin carryops for dummy pointers (#157490)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 10 21:57:37 PDT 2025
Author: Timm Baeder
Date: 2025-09-11T06:57:33+02:00
New Revision: 8fae5a51321d5d807b0cb6982fb2e07c66948f59
URL: https://github.com/llvm/llvm-project/commit/8fae5a51321d5d807b0cb6982fb2e07c66948f59
DIFF: https://github.com/llvm/llvm-project/commit/8fae5a51321d5d807b0cb6982fb2e07c66948f59.diff
LOG: [clang][bytecode] Check builtin carryops for dummy pointers (#157490)
Fixes #157422
Added:
Modified:
clang/lib/AST/ByteCode/InterpBuiltin.cpp
clang/test/AST/ByteCode/builtins.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 91deda980b57e..4461731c25648 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -913,6 +913,9 @@ static bool interp__builtin_carryop(InterpState &S, CodePtr OpPC,
APSInt RHS = popToAPSInt(S.Stk, RHST);
APSInt LHS = popToAPSInt(S.Stk, LHST);
+ if (CarryOutPtr.isDummy())
+ return false;
+
APSInt CarryOut;
APSInt Result;
diff --git a/clang/test/AST/ByteCode/builtins.cpp b/clang/test/AST/ByteCode/builtins.cpp
index 9b2b20773be58..33b703c24cb51 100644
--- a/clang/test/AST/ByteCode/builtins.cpp
+++ b/clang/test/AST/ByteCode/builtins.cpp
@@ -36,3 +36,10 @@ void test_builtin_os_log(void *buf, int i, const char *data) {
constexpr int len = __builtin_os_log_format_buffer_size("%d %{public}s %{private}.16P", i, data, data);
static_assert(len > 0, "Expect len > 0");
}
+
+void addc_dummy()
+{
+ unsigned int a;
+ if (__builtin_addc (1, 42, 0, &a))
+ __builtin_abort ();
+}
More information about the cfe-commits
mailing list