Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Format/WhitespaceManager.cpp
Show First 20 Lines • Show All 830 Lines • ▼ Show 20 Lines | AlignTokens( | ||||
if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0) | if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0) | ||||
return false; | return false; | ||||
// Do not align operator= overloads. | // Do not align operator= overloads. | ||||
FormatToken *Previous = C.Tok->getPreviousNonComment(); | FormatToken *Previous = C.Tok->getPreviousNonComment(); | ||||
if (Previous && Previous->is(tok::kw_operator)) | if (Previous && Previous->is(tok::kw_operator)) | ||||
return false; | return false; | ||||
return Style.AlignConsecutiveAssignments.AlignCompound | return Style.AlignConsecutiveAssignments.AlignCompound | ||||
? C.Tok->getPrecedence() == prec::Assignment | ? C.Tok->getPrecedence() == prec::Assignment | ||||
: C.Tok->is(tok::equal); | : (C.Tok->is(tok::equal) || | ||||
// In Verilog the '<=' is not a compound assignment, thus | |||||
// it is aligned even when the AlignCompound option is not | |||||
// set. | |||||
(Style.isVerilog() && C.Tok->is(tok::lessequal) && | |||||
C.Tok->getPrecedence() == prec::Assignment)); | |||||
}, | }, | ||||
HazardyKnusperkeks: Do you need the extra case, or could you just activate `AlignCompound`?
If you do, can you… | |||||
If I get you right, you are suggesting that AlignCompound: false is there only for backward compatibility, and we can make it default to true since we don't have to maintain backward compatibility for new things. I prefer consistency. sstwcw: If I get you right, you are suggesting that `AlignCompound: false` is there only for backward… | |||||
Changes, /*StartAt=*/0, Style.AlignConsecutiveAssignments, | Changes, /*StartAt=*/0, Style.AlignConsecutiveAssignments, | ||||
/*RightJustify=*/true); | /*RightJustify=*/true); | ||||
} | } | ||||
void WhitespaceManager::alignConsecutiveBitFields() { | void WhitespaceManager::alignConsecutiveBitFields() { | ||||
if (!Style.AlignConsecutiveBitFields.Enabled) | if (!Style.AlignConsecutiveBitFields.Enabled) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 706 Lines • Show Last 20 Lines |
Do you need the extra case, or could you just activate AlignCompound?
If you do, can you please add parens, the precedence of ? and : in combination with || is at least for me not 100% clear.