[all-commits] [llvm/llvm-project] cef638: [Bounds-Safety] Temporarily relax a `counted_by` a...
Dan Liew via All-commits
all-commits at lists.llvm.org
Fri May 17 16:24:31 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cef6387e52578366c2332275dad88b9953b55336
https://github.com/llvm/llvm-project/commit/cef6387e52578366c2332275dad88b9953b55336
Author: Dan Liew <dan at su-root.co.uk>
Date: 2024-05-17 (Fri, 17 May 2024)
Changed paths:
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/Sema/SemaDeclAttr.cpp
M clang/test/Sema/attr-counted-by-vla.c
Log Message:
-----------
[Bounds-Safety] Temporarily relax a `counted_by` attribute restriction on flexible array members
In 0ec3b972e58bcbcdc1bebe1696ea37f2931287c3 an additional restriction
was added when applying the `counted_by` attribute to flexible array
members in structs. The restriction prevented the element type being
a struct that itself had a flexible array member. E.g.:
```
struct has_unannotated_VLA {
int count;
char buffer[];
};
struct buffer_of_structs_with_unnannotated_vla {
int count;
struct has_unannotated_VLA Arr[] __counted_by(count);
};
```
In this example assuming the size of `Arr` is `sizeof(struct
has_unannotated_VLA)*count` (which is what the attribute says) is wrong
because it doesn't account for the size of
`has_unannotated_VLA::buffer`. This is why this kind of code construct
was treated as an error.
However, it turns out existing Linux kernel code used the attribute
on a flexible array member in this way
(https://github.com/llvm/llvm-project/pull/90786#issuecomment-2118416515).
To unbreak the build this restriction is downgraded to a warning with
the plan to make it an error again once the errornous use of the
attribute in the Linux kernel is resolved.
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