[clang] a21521a - [clang][bytecode] Check builtin carryops for non-block out pointers (#165512)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 28 23:30:15 PDT 2025


Author: Timm Baeder
Date: 2025-10-29T07:30:11+01:00
New Revision: a21521a4efacba405964767a8c2280b40aa68536

URL: https://github.com/llvm/llvm-project/commit/a21521a4efacba405964767a8c2280b40aa68536
DIFF: https://github.com/llvm/llvm-project/commit/a21521a4efacba405964767a8c2280b40aa68536.diff

LOG: [clang][bytecode] Check builtin carryops for non-block out pointers (#165512)

Fixes https://github.com/llvm/llvm-project/issues/165372

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/InterpBuiltin.cpp
    clang/test/AST/ByteCode/builtin-functions.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index ab6b3ed1be0aa..b3ab82da5e01a 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -859,7 +859,7 @@ static bool interp__builtin_carryop(InterpState &S, CodePtr OpPC,
   APSInt RHS = popToAPSInt(S.Stk, RHST);
   APSInt LHS = popToAPSInt(S.Stk, LHST);
 
-  if (CarryOutPtr.isDummy())
+  if (CarryOutPtr.isDummy() || !CarryOutPtr.isBlockPointer())
     return false;
 
   APSInt CarryOut;

diff  --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp
index e9093b2f23f74..a90f636b5134b 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1856,7 +1856,8 @@ namespace InitParam {
 
 #endif
 
-namespace SAddOverflowInt {
+namespace NonBlockPointerStore {
   int a;
   void foo(void) { a *= __builtin_sadd_overflow(1, 2, 0); }
+  void foo2(void) { a *= __builtin_addc(1, 2, 0, 0); }
 }


        


More information about the cfe-commits mailing list