forked from OSchip/llvm-project
clang-format: Improve cast detection (fix false positive).
Before: fn(a)(b)+1; After: fn(a)(b) + 1; llvm-svn: 212935
This commit is contained in:
parent
6a931f507a
commit
3064620d0d
|
@ -841,6 +841,8 @@ private:
|
|||
FormatToken *LeftOfParens = nullptr;
|
||||
if (Tok.MatchingParen)
|
||||
LeftOfParens = Tok.MatchingParen->getPreviousNonComment();
|
||||
if (LeftOfParens && LeftOfParens->is(tok::r_paren))
|
||||
return false;
|
||||
bool IsCast = false;
|
||||
bool ParensAreEmpty = Tok.Previous == Tok.MatchingParen;
|
||||
bool ParensAreType = !Tok.Previous ||
|
||||
|
|
|
@ -4975,6 +4975,7 @@ TEST_F(FormatTest, FormatsCasts) {
|
|||
verifyFormat("return (my_int)aaa;");
|
||||
verifyFormat("#define x ((int)-1)");
|
||||
verifyFormat("#define p(q) ((int *)&q)");
|
||||
verifyFormat("fn(a)(b) + 1;");
|
||||
|
||||
verifyFormat("void f() { my_int a = (my_int)*b; }");
|
||||
verifyFormat("void f() { return P ? (my_int)*P : (my_int)0; }");
|
||||
|
|
Loading…
Reference in New Issue