[clang] [BoundsSafety][Sema] Allow counted_by and counted_by_or_null on pointers where the pointee type is incomplete but potentially completable (PR #106321)
Dan Liew via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 8 07:09:25 PST 2025
================
@@ -19,13 +19,12 @@ struct on_member_pointer_complete_ty {
};
struct on_member_pointer_incomplete_ty {
- struct size_unknown * buf __counted_by(count); // expected-error{{'counted_by' cannot be applied to a pointer with pointee of unknown size because 'struct size_unknown' is an incomplete type}}
+ struct size_unknown * buf __counted_by(count); // ok
----------------
delcypher wrote:
@AaronBallman I should have also noted the current design also allows for headers that deliberately don't provide complete types to reduce compile times which I believe is fairly common practice.
E.g.
```
// some_data.h
struct SomeData {
int value;
};
// list_handle.h
// Forward declare to avoid needing to include `some_data.h`
struct SomeData;
struct ListHandle {
struct SomeData* __counted_by(count) items;
size_t count;
};
```
https://github.com/llvm/llvm-project/pull/106321
More information about the cfe-commits
mailing list