[all-commits] [llvm/llvm-project] 41a620: [lldb] Fix 32-bit narrowing conversions in the mem...

Yao Qi via All-commits all-commits at lists.llvm.org
Mon Sep 14 06:52:27 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 41a620da5a34d3e6256dc25e0c7c51c4afa8576d
      https://github.com/llvm/llvm-project/commit/41a620da5a34d3e6256dc25e0c7c51c4afa8576d
  Author: Yao Qi <yao_qi at apple.com>
  Date:   2026-09-14 (Mon, 14 Sep 2026)

  Changed paths:
    M lldb/source/Target/Memory.cpp
    M lldb/unittests/Target/MemoryTest.cpp

  Log Message:
  -----------
  [lldb] Fix 32-bit narrowing conversions in the memory cache (#223402)

#222688 broke the 32-bit Arm bots.  `lldb-arm-ubuntu` fails to
build `Memory.cpp`:

```
lldb/source/Target/Memory.cpp:187:49: error: non-constant-expression cannot be narrowed from type 'lldb::offset_t' (aka 'unsigned long long') to 'size_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]
 187 |   InsertData(addr, {data_buffer_sp->GetBytes(), data_buffer_sp->GetByteSize()});
     |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

`DataBuffer::GetByteSize` returns `lldb::offset_t`, which is always 64
bits wide, while the `llvm::ArrayRef` constructor takes a `size_t`.
Where
`size_t` is 32 bits the conversion narrows, and a braced initializer
list
rejects a narrowing conversion that is not a constant expression.  The
same code compiles on a 64-bit host because there `size_t` is just as
wide
as `offset_t` and nothing narrows.

`DataBuffer::GetData` already returns the whole buffer as an
`llvm::ArrayRef<uint8_t>`, so use it rather than build the same
`ArrayRef`
from a pointer and a length.

`MemoryTest.cpp` has eight more of the same error, which the bot never
reported because the build stopped at the first one. They share a single
cause: `line` holds the cache line size, but it was declared `addr_t`
and
the `Chunk` field it initializes is a `size_t`.  Give it the type
`MemoryCache::GetMemoryCacheLineSize` returns, `uint32_t`, which is also
the right domain for a size rather than an address.

Assisted-by: claude



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list