[clang] [clang][bytecode] Check builtin carryops for dummy pointers (PR #157490)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 8 08:24:47 PDT 2025
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/157490
Fixes #157422
>From b8619e89a789c865c1ee00a4b4ea46457d79cbd9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Mon, 8 Sep 2025 17:21:36 +0200
Subject: [PATCH] [clang][bytecode] Check builtin carryops for dummy pointers
Fixes #157422
---
clang/lib/AST/ByteCode/InterpBuiltin.cpp | 3 +++
clang/test/AST/ByteCode/builtins.cpp | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index a0dcdace854b9..0c22890a00dbb 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -910,6 +910,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