[clang] [attributes][-Wunsafe-buffer-usage] Support adding unsafe_buffer_usage attribute to struct fields (PR #101585)
Malavika Samak via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 2 15:54:12 PDT 2024
================
@@ -2261,6 +2262,12 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
// note_unsafe_buffer_operation doesn't have this mode yet.
assert(!IsRelatedToDecl && "Not implemented yet!");
MsgParam = 3;
+ } else if (isa<MemberExpr>(Operation)) {
+ // note_unsafe_buffer_operation doesn't have this mode yet.
+ assert(!IsRelatedToDecl && "Not implemented yet!");
+ auto ME = dyn_cast<MemberExpr>(Operation);
+ name = ME->getMemberDecl()->getName();
----------------
malavikasamak wrote:
Sounds good, I will use the Decl and also add a test. I wasn't aware that it is unusual to put a field name in there.
Side note: we should probably also provide the Decl, when the attribute is added to method overloads. Perhaps that needs to be a separate PR?
https://github.com/llvm/llvm-project/pull/101585
More information about the cfe-commits
mailing list