[PATCH] D148381: [Clang] Implement the 'counted_by' attribute

2023-09-15 Thread Yeoul Na via Phabricator via cfe-commits
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

[PATCH] D148381: [WIP][Clang] Add counted_by attribute

2023-08-23 Thread Yeoul Na via Phabricator via cfe-commits
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

[PATCH] D148381: [WIP][Clang] Add counted_by attribute

2023-08-23 Thread Yeoul Na via Phabricator via cfe-commits
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/

[PATCH] D148381: [WIP][Clang] Add counted_by attribute

2023-08-23 Thread Yeoul Na via Phabricator via cfe-commits
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-

[PATCH] D157445: [CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash.

2023-08-15 Thread Yeoul Na via Phabricator via cfe-commits
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

[PATCH] D157445: [CodeGen][UBSan] Add support for handling attributed functions in getUBSanFunctionTypeHash.

2023-08-10 Thread Yeoul Na via Phabricator via cfe-commits
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