[PATCH] D95536: [clang][sema] Note decl location on missing member
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 9 13:06:54 PST 2021
aaron.ballman added a comment.
In D95536#2551332 <https://reviews.llvm.org/D95536#2551332>, @tbaeder wrote:
> Any update on this?
Thank you for the patch! Do you have some motivating examples of when this would really add clarity to the diagnostic? I'm not opposed to the patch per se, but I'm a bit wary about adding an additional note because that makes the diagnostic output seem that much longer, which makes the salient diagnostics a bit harder to find (colorization in the terminal helps with this, though).
> The patch only emits the note if clang does not output a typo correction. I thought it might not be as useful in this case since it would clutter the output and chances are that the typo fix _is_ the right thing to show. Opinions on this?
I think that makes sense -- the typo correction already has a note that points to somewhere which is likely to get the user into the right area anyway: https://godbolt.org/z/1Yo3Pj
================
Comment at: clang/include/clang/Sema/Sema.h:9795
+ /// Report a Note for an unknown member of the given decl context
+ void reportDeclForUnknownMember(const DeclContext *Ctx);
----------------
================
Comment at: clang/lib/Sema/Sema.cpp:2549
+void Sema::reportDeclForUnknownMember(const DeclContext *Ctx) {
+ // Don't report the global scope decl
+ if (isa<TranslationUnitDecl>(Ctx))
----------------
================
Comment at: clang/lib/Sema/Sema.cpp:2553
+
+ // Lambdas already report their declaration location themselves
+ if (isa<CXXRecordDecl>(Ctx) && cast<CXXRecordDecl>(Ctx)->isLambda())
----------------
================
Comment at: clang/lib/Sema/Sema.cpp:2557-2560
+ if (const Decl *D = dyn_cast<Decl>(Ctx)) {
+ Diag(D->getLocation(), diag::note_entity_declared_at)
+ << Ctx << D->getLocation();
+ }
----------------
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95536/new/
https://reviews.llvm.org/D95536
More information about the cfe-commits
mailing list