[all-commits] [llvm/llvm-project] 3783db: [lldb] [NFC] Fix unused variable warning in Memory...

Yao Qi via All-commits all-commits at lists.llvm.org
Mon Sep 21 01:28:36 PDT 2026


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

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

  Log Message:
  -----------
  [lldb] [NFC] Fix unused variable warning in MemoryCache::InsertPartialLine (#224973)

A Release build (assertions disabled) warns:

```
lldb/source/Target/Memory.cpp:144:18: warning: unused variable 'line_size' [-Wunused-variable]
  144 |   const uint32_t line_size = m_L2_cache.GetLineByteSize();
      |                  ^~~~~~~~~
```

`line_size` was read only inside the `assert` that checks a partial-line
insert does not cross a cache line boundary. `assert` expands to nothing
when `NDEBUG` is defined, so the variable becomes unused in that
configuration.

`llvm/docs/CodingStandards.md` covers this shape directly:
```
In the first case, the call to `V.size()` is only useful for the assert,
and we don't want it executed when assertions are disabled.  Code like
this should move the call into the assert itself.
```
so call `GetLineByteSize()` in the assert and drop the local.

Verified by building `lldb/source/Target/Memory.cpp` with
`-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF`: the warning
above reproduces before this change and is gone after it, with a clean
rebuild of the same object file.



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