forked from OSchip/llvm-project
clang-format: Understand sequenced casts.
This fixed llvm.org/PR20712. Before: int i = (int)(int) -2; After: int i = (int)(int)-2; llvm-svn: 216378
This commit is contained in:
parent
7189fb2cf9
commit
4b3ba214d0
|
@ -853,8 +853,9 @@ private:
|
|||
FormatToken *LeftOfParens = nullptr;
|
||||
if (Tok.MatchingParen)
|
||||
LeftOfParens = Tok.MatchingParen->getPreviousNonComment();
|
||||
if (LeftOfParens && LeftOfParens->is(tok::r_paren))
|
||||
return false;
|
||||
if (LeftOfParens && LeftOfParens->is(tok::r_paren) &&
|
||||
LeftOfParens->MatchingParen)
|
||||
LeftOfParens = LeftOfParens->MatchingParen->Previous;
|
||||
if (LeftOfParens && LeftOfParens->is(tok::r_square) &&
|
||||
LeftOfParens->MatchingParen &&
|
||||
LeftOfParens->MatchingParen->Type == TT_LambdaLSquare)
|
||||
|
|
|
@ -5057,6 +5057,7 @@ TEST_F(FormatTest, FormatsCasts) {
|
|||
verifyFormat("my_int a = (my_int *)1;");
|
||||
verifyFormat("my_int a = (const my_int)-1;");
|
||||
verifyFormat("my_int a = (const my_int *)-1;");
|
||||
verifyFormat("my_int a = (my_int)(my_int)-1;");
|
||||
|
||||
// FIXME: single value wrapped with paren will be treated as cast.
|
||||
verifyFormat("void f(int i = (kValue)*kMask) {}");
|
||||
|
|
Loading…
Reference in New Issue