[clang] [clang][bytecode] Check builtin carryops for dummy pointers (PR #157490)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 8 08:25:24 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
Fixes #<!-- -->157422
---
Full diff: https://github.com/llvm/llvm-project/pull/157490.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+3)
- (modified) clang/test/AST/ByteCode/builtins.cpp (+7)
``````````diff
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 ();
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/157490
More information about the cfe-commits
mailing list