[all-commits] [llvm/llvm-project] 6cafa8: [lldb][NativePDB] Use active bits for constant wid...
Nerixyz via All-commits
all-commits at lists.llvm.org
Fri Jul 17 02:49:01 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6cafa889cd398ca70992e0df518b2414a2607327
https://github.com/llvm/llvm-project/commit/6cafa889cd398ca70992e0df518b2414a2607327
Author: Nerixyz <nerixdev at outlook.de>
Date: 2026-07-17 (Fri, 17 Jul 2026)
Changed paths:
M lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
M lldb/test/Shell/SymbolFile/NativePDB/Inputs/globals-fundamental.lldbinit
M lldb/test/Shell/SymbolFile/NativePDB/globals-fundamental.cpp
A lldb/test/Shell/SymbolFile/NativePDB/static-class-constants.cpp
Log Message:
-----------
[lldb][NativePDB] Use active bits for constant width (#196104)
Static constants with bit widths less than 16 (e.g. char/unsigned char)
in classes were not available. These constants are still encoded with 16
bits
([here](https://github.com/llvm/llvm-project/blob/dd145eb8997878143f648a7601741f6409330963/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp#L341-L343))
even though they only need less bits. When we tried to create an
initializer for them, we'd check if the bit width (=16) was small enough
to fit into the target (<16). This would fail.
This was a problem in the following code:
```cpp
struct Foo {
// width(unsigned char) = 8, but 255 was encoded and read as 16 bit
static constexpr unsigned char u8_max = 255;
};
```
This PR fixes the issue by using `APSInt::getActiveBits` for unsigned
types and `APSInt::getSignificantBits` for signed types. They get the
number of bits required to encode the value. For example a constant 64
would need 7 bits in unsigned and 8 bits in signed types.
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