Lambdas with trailing return type 'auto' are annotated incorrectly. It causes a misformatting. The simpliest code to reproduce is:
auto list = {[]() -> auto { return 0; }};
Differential D130299
[clang-format] FIX: Misannotation 'auto' as trailing return type in lambdas denis-fatkulin on Jul 21 2022, 12:42 PM. Authored by
Details Lambdas with trailing return type 'auto' are annotated incorrectly. It causes a misformatting. The simpliest code to reproduce is: auto list = {[]() -> auto { return 0; }};
Diff Detail Event TimelineComment Actions Could you please add full git context? Comment Actions
I updated the patch with properly git context. Thanks!
I'm not sure about the questions. I will try to explain my patch purpose. Actually there was two problems:
Both cases are checked in changes at clang/unittests/Format/FormatTest.cpp and I think the unit test is sufficient. Comment Actions The question is, wether auto did get the type kw_auto before your change or not. If not a test for the token annotator would be in place. See e.g. D129946.
Comment Actions Patch is splitted, as suggested by @HazardyKnusperkeks This piece of changes is related to misannotation KW 'auto' as trailing return type in lambdas. Also, appropriate test is added. Comment Actions Thanks for the changes.
Comment Actions Do you have commit access, or do you want to apply for it, or do you need someone to push the change(s)? If the latter we need a name and mail for the commit. Comment Actions I haven't access for merging changes to code base. So, I need support from community for doing this. My name and mail: Thank you! PS. Related patch should be merged too. D130417 |