Keep space before or after the &/&& tokens, but not both. For example,
auto [x,y] = a; auto &[xr, yr] = a; // LLVM style auto& [xr, yr] = a; // google style
Differential D35743
[clang-format] Adjust space around &/&& of structured bindings chh on Jul 21 2017, 3:47 PM. Authored by
Details Keep space before or after the &/&& tokens, but not both. For example, auto [x,y] = a; auto &[xr, yr] = a; // LLVM style auto& [xr, yr] = a; // google style
Diff Detail
Event TimelineComment Actions Please add all the tests into unittests/Format/FormatTest.cpp instead. We use FileCheck-based tests only to verify the behavior of the clang-format binary itself. Comment Actions Generally, please upload patches with full context to phabricator. (or use arc) I think this approach is a bit inside out. We are in a codepath where we try to find a lambda introducer and we the look one or two tokens back to see that we aren't as we have seen "auto". I wonder whether we could instead see "auto" and understand that now we have to parse a declaration. Manuel, any thoughts? Comment Actions Daniel, Manuel, I will take over this CL since Yan has finished his internship at Google., Could you suggest if there is any better way to handle the new syntax? Comment Actions An alternative would be to look for auto (&&?)? [ with look-ahead, but I agree that this fits the "we try to parse a lambda introducer with look-behind" strategy we've so far been taking, so I'm fine with this approach. Comment Actions So we actually didn't need to change the UnwrappedLineParser? I assume we still incorrectly assume the structured bindings are labmdas then? Comment Actions There is one big missing thing here: PointerAlignment. Actually only PAS_Left is taken into account. Comment Actions Ok, we still need to fix structured bindings in the UnwrappedLineParser. Unfortunately isCppStructuredBinding requires a "previous token" function, which we don't really have in the UnwrappedLineParser. /me goes thinking more about that part of the problem. That should be largely independent of this patch, though, so LG from my side. Comment Actions
(and I just notice that I didn't fully clang-format my last patch, argh!) Comment Actions Apart from nits, LGTM, unless Daniel sees issues.
Comment Actions Could you add just one more test for PAS_Middle please? A single line will be just enough. |