[PATCH] D151720: [clang][ExprConstant] Fix display of syntactically-invalid note for member function calls

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 10:22:51 PDT 2023


erichkeane added inline comments.


================
Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:994
+static_assert(sobj.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'sobj.f()'}}
+static_assert(sptr->f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'sobj.f()'}}
+static_assert(slref.f(), ""); // expected-error {{constant expression}} expected-note {{in call to 'sobj.f()'}}
----------------
hazohelet wrote:
> erichkeane wrote:
> > So I think this is just trading 1 'wrong' for another.  We should be looking to see if we can figure out whether this is called with an arrow or not.  I don't have a good way of doing that unfortunately, but perhaps Aaron has an idea?
> I believe there might be a slight misunderstanding.
> The note generated for the `sptr->f()` will be `sobj.f()`, and not `sptr.f()`, so I think this patch does not introduce something wrong here.
> Note: BEFORE this patch, invalid code `&sobj->f()` is generated for this line.
> link: https://godbolt.org/z/vPWjdeqcK
> 
> That said, I think it would be ideal to distinguish `sptr` and `sobj` here, but I am unsure whether we can achieve it without incurring additional memory footprint.
Ah, I see, less bad then I think.  I'm on the fence here, this seems like it is still not great messaging.  GCC manages to maintain the `sptr` here, which I wish we could do (though they have an odder way of printing it all the same: https://godbolt.org/z/Kn3Mn75rh).

I think I want to see what Aaron says when he gets back next week.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151720/new/

https://reviews.llvm.org/D151720



More information about the cfe-commits mailing list