diff options
| author | Kees Cook <kees@kernel.org> | 2025-11-06 19:10:36 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-06 19:10:36 -0800 |
| commit | f29955a594aedf5943d492a999b83e8c6b8fafae (patch) | |
| tree | e7fd75db6ffde957b10992640f02f75347109381 /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | |
| parent | c88e207bf16f3f6467c1a55dbda58070313a02e7 (diff) | |
| download | llvm-f29955a594aedf5943d492a999b83e8c6b8fafae.zip llvm-f29955a594aedf5943d492a999b83e8c6b8fafae.tar.gz llvm-f29955a594aedf5943d492a999b83e8c6b8fafae.tar.bz2 | |
[Clang][Sema] Allow counted_by on void* as GNU extension (#164737)
The counted_by attribute currently rejects void* members because void
has no defined size. However, the sized_by attribute accepts void* since
it explicitly measures bytes. As a GNU extension, void pointer
arithmetic treats void as having size 1 byte, so counted_by on void*
should behave identically to sized_by (treating the count as bytes).
Allow counted_by on void* as a GNU extension. The implementation
validates this only at declaration time in SemaBoundsSafety.cpp,
emitting a -Wpointer-arith warning that the attribute is treated as a
GNU extension equivalent to sized_by. Both use-site validation and code
generation trust this earlier validation, avoiding redundant checks.
In CodeGen, __builtin_dynamic_object_size now correctly handles
counted_by on void* by treating any CountAttributedType with zero
element size as having 1-byte elements, matching the GNU void pointer
arithmetic semantics.
Add tests validating both Sema diagnostics and CodeGen behavior (correct
byte counts from __builtin_dynamic_object_size). Update existing
counted_by tests to explicitly use -Wpointer-arith to preserve their
original intent of rejecting void* in strict C mode.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp')
0 files changed, 0 insertions, 0 deletions
