Skip to content

Commit 981d296

Browse files
tbaederraokblast
authored andcommitted
[clang][bytecode] Check overflow ops for block pointers (llvm#165221)
We can't save the result in a non-block pointer. Fixes llvm#165076
1 parent b5cc001 commit 981d296

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ static bool interp__builtin_overflowop(InterpState &S, CodePtr OpPC,
749749
const CallExpr *Call,
750750
unsigned BuiltinOp) {
751751
const Pointer &ResultPtr = S.Stk.pop<Pointer>();
752-
if (ResultPtr.isDummy())
752+
if (ResultPtr.isDummy() || !ResultPtr.isBlockPointer())
753753
return false;
754754

755755
PrimType RHST = *S.getContext().classify(Call->getArg(1)->getType());

clang/test/AST/ByteCode/builtin-functions.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,3 +1855,8 @@ namespace InitParam {
18551855
}
18561856

18571857
#endif
1858+
1859+
namespace SAddOverflowInt {
1860+
int a;
1861+
void foo(void) { a *= __builtin_sadd_overflow(1, 2, 0); }
1862+
}

0 commit comments

Comments
 (0)