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

Takuya Shimizu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 30 10:13:21 PDT 2023


hazohelet added a comment.

Thanks for the feedback.



================
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()'}}
----------------
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.


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