[PATCH] D95691: Implement P2173 for attributes on lambdas

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 29 11:39:28 PST 2021


aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rjmccall, jyknight.
aaron.ballman requested review of this revision.

https://wg21.link/P2173 is making its way through WG21 currently and has not been formally adopted yet. This feature provides very useful functionality in that you can specify attributes on the various function *declarations* generated by a lambda expression, where the current C++ grammar only allows attributes which apply to the various function *types* so generated.

This patch implements P2173 <https://reviews.llvm.org/P2173> on the assumption that it will be adopted by WG21 with this syntax because there are no other syntactic locations to put an attribute on a lambda that will unambiguously appertain to the declaration rather than the type. Given the large number of function declaration attributes compared to function type attributes, such a construct is needed. The proposal has been approved in principle by EWG and is scheduled to go through Core wording review, so there is a strong likelihood it will be adopted, at least with this syntax. When WG21 adopts the proposal, the diagnostic can be changed as appropriate. In the unlikely event that WG21 decides not to adopt the proposal, this syntax is still a conforming extension.

I need this functionality in a downstream fork of Clang that is currently sliding some attributes written in the type position to instead apply to the declaration.


https://reviews.llvm.org/D95691

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/AST/ast-dump-lambda.cpp
  clang/test/Parser/cxx0x-lambda-expressions.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95691.320178.patch
Type: text/x-patch
Size: 8617 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210129/ee79fca4/attachment.bin>


More information about the cfe-commits mailing list