forked from OSchip/llvm-project
clang-format: Fix unary operator detection in for loops.
Before: for (;; * a = b) {} After: for (;; *a = b) {} llvm-svn: 242849
This commit is contained in:
parent
1c65094d5b
commit
bcad06640b
|
@ -836,7 +836,8 @@ private:
|
|||
Contexts.back().IsExpression = true;
|
||||
if (!Line.startsWith(TT_UnaryOperator)) {
|
||||
for (FormatToken *Previous = Current.Previous;
|
||||
Previous && !Previous->isOneOf(tok::comma, tok::semi);
|
||||
Previous && Previous->Previous &&
|
||||
!Previous->Previous->isOneOf(tok::comma, tok::semi);
|
||||
Previous = Previous->Previous) {
|
||||
if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
|
||||
Previous = Previous->MatchingParen;
|
||||
|
|
|
@ -5458,6 +5458,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
|
|||
FormatStyle Left = getLLVMStyle();
|
||||
Left.PointerAlignment = FormatStyle::PAS_Left;
|
||||
verifyFormat("x = *a(x) = *a(y);", Left);
|
||||
verifyFormat("for (;; * = b) {\n}", Left);
|
||||
|
||||
verifyIndependentOfContext("a = *(x + y);");
|
||||
verifyIndependentOfContext("a = &(x + y);");
|
||||
|
|
Loading…
Reference in New Issue