================ @@ -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(); ---------------- haoNoQ wrote:
I suspect that this one will crash in case of anonymous fields. That said, I also don't think it's even possible to put an attribute on an anonymous field, so we're probably fine. However, with diagnostics specifically, the tradition isn't to put `name` into the `Diag()` stream; the tradition is to put the decl itself, directly, by pointer into the Diag() stream! I.e. ```c++ const Decl *D = ME->getMemberDecl(); ... S.Diag(Loc, diag::warn_unsafe_buffer_operation) << MsgParam << D << Range; ``` This way not only it reacts to anonymous objects correctly (I think), but also it automatically puts quotes around the name, which is something we currently forget to do :) https://github.com/llvm/llvm-project/pull/101585 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits