Skip to content

Commit c5ed2a1

Browse files
committed
[BoundsSafety][lldb] Avoid use of __builtin_add_overflow for portability with MSVC
1 parent 74ecedd commit c5ed2a1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lldb/source/DataFormatters/FormattersHelpers.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ static std::optional<OOBInfo> GetOOBInfo(lldb::addr_t ptr,
8585
elt_size = 1;
8686
}
8787

88-
lldb::addr_t ptr_upper_bound = ptr;
88+
lldb::addr_t ptr_upper_bound = ptr + elt_size;
8989
// We consider an access that would overflow the address space also
9090
// out-of-bounds.
91-
bool overflow = __builtin_add_overflow(ptr, elt_size, &ptr_upper_bound);
92-
if (overflow)
91+
if (ptr_upper_bound < ptr)
9392
return OOBInfo{LLDB_INVALID_ADDRESS, OOBKind::Overflow};
9493

9594
// Note `ptr_upper_bound == upper_bound` is ok because that corresponds

0 commit comments

Comments
 (0)