[qt/clang/llvm-project]: Summary of bulk changes made

KDE Git Services - Bulk Change <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git repository change summary for qt/clang/llvm-project
Pushed by mirror-service into branch 'upstream/users/delcypher/fix-or_null_sized_by-codegen-bugs-part-2'.
Changed from 0000000000000000000000000000000000000000 to 14cb4c04f324d1b4d913bea1a6f89997ea788e77
Acknowledgement was received that this change introduces only existing code that has been pushed to another public open source repository.

This change contains the following new commits:

Git commit f306c2741b5334dedc34513cf1eab875defa86c3 by Dan Liew on 03/08/2026 at 22:34..
[CodeGen][NFC] Split __sized_by tests into their own file and rename test cases

In future patches the coverage of the __counted_by family attributes is
going to be increased. To help with this patch refactors the existing
test file.

1. Split `__sized_by` tests into their own file. In later commits files
   will be added for each attribute so it makes sense for each attribute
   to have its own file.
2. Replace `testN` test case names with human readable descriptions. Not
   all test cases that will be added in the future will apply to all
   attributes. If we kept on using the `testN` naming convention it
   would leave odd gaps in the test numbering because we try to keep
   what a test case tests consistent between files (i.e. `testN` would
   roughly test the same thing but with a different attribute). Using
   named test cases completely avoids this.
https://invent.kde.org/qt/clang/llvm-project/-/commit/f306c2741b5334dedc34513cf1eab875defa86c3

Git commit 14cb4c04f324d1b4d913bea1a6f89997ea788e77 by Dan Liew on 03/08/2026 at 22:39..
[CodeGen] Fix __builtin_dynamic_object_size for __sized_by / _or_null pointers

`emitCountedByPointerSize()` assumed a CountAttributedType is always
a __counted_by pointer. That isn't true, there are four versions of the
attribute:

* `__counted_by`: Already handled correctly.
* `__counted_by_or_null`: Incorectly handled.
* `__sized_by`: Incorreclty handled.
* `__sized_by_or_null`: Incorreclty handled.

In particular:

* __sized_by / __sized_by_or_null: the attribute argument is a byte count,
  but the object size was computed as count * sizeof(*ptr), over-reporting by
  the element size for any pointee larger than one byte. Use the count
  directly for the byte-counting variants.

* __counted_by_or_null / __sized_by_or_null: a null pointer describes no
  accessible memory, but the null case was ignored. Emit
  'count = ptr ? count : 0' so __bdos reports 0 for a null pointer. The null
  check needs the pointer value; where the size query already has one emitted
  (the pass_dynamic_object_size path, or a non-volatile field) it reuses that
  value rather than re-loading the field, so a volatile pointer field is
  loaded once rather than twice (except in the '&ptr[idx]' form, where the
  pointer is re-emitted; see the FIXME). A direct __bdos(p->buf) on a volatile
  field never reaches this path: like sizeof, __bdos bails to the default
  rather than emit a side-effecting volatile load just to answer a size query,
  so the field is loaded zero times (see test_bdos_of_volatile_pointer).

* __sized_by on a pointer to an incomplete (forward-declared) type
  crashed: the annotated pointee's element size was computed
  unconditionally, and getTypeSizeInChars() asserts on an incomplete
  type. The element size is only needed for __counted_by (whose pointee
  Sema guarantees is complete at a use site) and for scaling an index
  (whose element type is complete because it is being subscripted), so
  only compute it there.

Assisted-by: Claude Code
https://invent.kde.org/qt/clang/llvm-project/-/commit/14cb4c04f324d1b4d913bea1a6f89997ea788e77
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.