rapidsna added a comment.
struct V {
int Sizes[2];
int FAM[] __counted_by(Sizes[0]); // Thoughts?
};
`-fbounds-safety` doesn't allow this. In our internal adoption experience, we
haven't encountered such use cases yet. So, I think it's best to make the model
restrictive to avoid sur
rapidsna added inline comments.
Comment at: clang/lib/Sema/SemaDecl.cpp:17931
+ auto It = llvm::find_if(RD->fields(), [&](const FieldDecl *Field) {
+return Field->getName() == ECA->getCountedByField()->getName();
+ });
What happens in this corner case where
rapidsna added inline comments.
Comment at: clang/include/clang/Basic/AttrDocs.td:7209
+/* ... */
+struct bar *fam[] __attribute__((counted_by(num_fam_elements)));
+ };
I don't think it's necessary for this patch but for [[
https://discourse.llvm.org/t/
rapidsna added a comment.
> Future additions will include supporting, FAMs and counts in
sub-structures.
For sub-structures, are you referring to cases like this?
struct outer {
struct {
int count;
} sub;
int flex[__attribute__((counted_by(sub.count)))];
};
For `-fbounds-
rapidsna accepted this revision.
rapidsna added a comment.
This revision is now accepted and ready to land.
The changes look good to me. Ideally, we could add tests with multiple
attributes and possibly with other sugar types.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
h
rapidsna requested changes to this revision.
rapidsna added a comment.
This revision now requires changes to proceed.
We should add a test to exercise when `Ty` is wrapped by other sugar types.
Could you try with `typedef`?
Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:573