[PATCH] D58934: [clang-format] Fix lambdas returning template specialization that contains operator in parameter

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 5 11:20:35 PST 2019


jkorous added a comment.

In D58934#1418043 <https://reviews.llvm.org/D58934#1418043>, @MyDeveloperDay wrote:

> I'm not sure I personally would ever write code like that ;-) , but if its legal C++ and it compiles we should handle it the same as foo<1>,foo<true>,foo<!true>


I hear you :D

> As there are a number of reviews out there for formatting Lambdas I think its a good idea for us to add corner cases like this to the unit tests, but it does get me thinking if this shouldn't be handled by a piece of code which knows about trailing return types (template or otherwise) and not be in the general Lambda parsing code
> 
> I suspect that given that the switch statement handles
> 
>   tok::identifier, tok::less, tok::numeric_constant, tok::greater
>   foo            <                          1              >
> 
> 
> We are effectively just consuming the return type tokens.
> 
> But to handle what you have here it LGTM and handles more use cases that https://bugs.llvm.org/show_bug.cgi?id=40910 would throw up.
> 
> Thanks for helping out

I had the same exact idea but since I wasn't able to find any existing function I just followed your lead for now. But I assume we can just factor out this later.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58934





More information about the cfe-commits mailing list