Ports r359967 to clang-format.
Details
- Reviewers
krasimir - Commits
- rG41f4d68a50be: clang-format: Add support for formatting (some) lambdas with explicit template…
rL371854: clang-format: Add support for formatting (some) lambdas with explicit template…
rC371854: clang-format: Add support for formatting (some) lambdas with explicit template…
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I'll need some more time to investigate the implications of this with respect to Objective-C disambiguation stuff.
Specifically, this may interact with funny ways with the heuristic outlined in (old) UnwrappedLineParser.cpp line 1453:
// In a C++ lambda a template type can only occur after an arrow. We use // this as an heuristic to distinguish between Objective-C expressions // followed by an `a->b` expression, such as: // ([obj func:arg] + a->b)
At least we'll have to update this comment accordingly, otherwise it will be confusing.
clang/lib/Format/TokenAnnotator.cpp | ||
---|---|---|
44 | nit: add a [ in the second case, like [...]<...>(. Also I'd suggest extending this sentence with: ", where the [ opens a lambda capture list", because we explicitly check the [ for that and to disambiguate between the case this is interested in and Objective-C method calls followed by function-invocation style call, like in [obj meth](). | |
50 | The first Left->Previous check is unnecessary here, following the previous if. | |
55 | nit: consider replacing with Check for `[...]` |
Thanks for the thorough review! Indeed, this still gets []<bool b = true && false>(A &&a){}(); wrong, for the reason you mention.
clang/lib/Format/TokenAnnotator.cpp | ||
---|---|---|
50 | I removed the previous if, it makes the function more symmetric. |
Do you think this should land with the comment FIXME for now? It improves formatting of this language feature when that heuristic is not used, and changing the heuristic is independent of the rest of this patch.
nit: add a [ in the second case, like [...]<...>(. Also I'd suggest extending this sentence with: ", where the [ opens a lambda capture list", because we explicitly check the [ for that and to disambiguate between the case this is interested in and Objective-C method calls followed by function-invocation style call, like in [obj meth]().