Skip to content

Commit 8fae5a5

Browse files
authored
[clang][bytecode] Check builtin carryops for dummy pointers (#157490)
Fixes #157422
1 parent 21b99e1 commit 8fae5a5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,9 @@ static bool interp__builtin_carryop(InterpState &S, CodePtr OpPC,
913913
APSInt RHS = popToAPSInt(S.Stk, RHST);
914914
APSInt LHS = popToAPSInt(S.Stk, LHST);
915915

916+
if (CarryOutPtr.isDummy())
917+
return false;
918+
916919
APSInt CarryOut;
917920

918921
APSInt Result;

clang/test/AST/ByteCode/builtins.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,10 @@ void test_builtin_os_log(void *buf, int i, const char *data) {
3636
constexpr int len = __builtin_os_log_format_buffer_size("%d %{public}s %{private}.16P", i, data, data);
3737
static_assert(len > 0, "Expect len > 0");
3838
}
39+
40+
void addc_dummy()
41+
{
42+
unsigned int a;
43+
if (__builtin_addc (1, 42, 0, &a))
44+
__builtin_abort ();
45+
}

0 commit comments

Comments
 (0)