Use spaces to align binary and ternary expressions when using AlignOperands and UT_AlignWithSpaces.
Details
- Reviewers
MyDeveloperDay curdeius - Group Reviewers
Restricted Project - Commits
- rGb18c63e85aa8: [clang-format] use spaces for alignment of binary/ternary expressions with…
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This fixes an oversight in the new UT_AlignWithSpaces option (see D75034), which did not correctly identify the alignment of binary/ternary expressions.
clang/lib/Format/ContinuationIndenter.cpp | ||
---|---|---|
1362–1367 | You could factor out the part of the condition that doesn't concern AlignOperands to get rid of the repetition wrt. the previous if. |
Thanks! I don't have push permissions to the repository so I cannot submit the commit myself (Maximilian Fickert <maximilian.fickert@gmail.com>).
Could this also be causing https://bugs.llvm.org/show_bug.cgi?id=33896 ?
I'll try to see if changes something in that case...
Actually, I can confirm this is unrelated.
clang/lib/Format/ContinuationIndenter.cpp | ||
---|---|---|
1364 | bad indent here : should be space-indented. |
Yes I think it's unrelated, though this patch should fix the alignment in that example when using the UT_AlignWithSpaces option.
clang/lib/Format/ContinuationIndenter.cpp | ||
---|---|---|
1364 | Can you clarify? This is formatted with the LLVM clang-format. |
clang/lib/Format/ContinuationIndenter.cpp | ||
---|---|---|
1364 | Phabricator shows some kind of >> symbol at the beginning of this line, which i interpreted as a TAB character, hence my comment. |
I am not 100% that it is thanks to this patch but reformatting Firefox code with clang-format 11 significantly improves the readability of the usage
of ternary operators. See: https://phabricator.services.mozilla.com/D90795
Thanks for the change!
bad indent here : should be space-indented.