forked from OSchip/llvm-project
clang-format: Fix cast detection on "this".
Before: auto x = (X) this; After: auto x = (X)this; This fixes llvm.org/PR27198. llvm-svn: 265385
This commit is contained in:
parent
c253f8b06b
commit
94b1bdf91a
|
@ -1172,9 +1172,9 @@ private:
|
||||||
if (!LeftOfParens)
|
if (!LeftOfParens)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the following token is an identifier, this is a cast. All cases where
|
// If the following token is an identifier or 'this', this is a cast. All
|
||||||
// this can be something else are handled above.
|
// cases where this can be something else are handled above.
|
||||||
if (Tok.Next->is(tok::identifier))
|
if (Tok.Next->isOneOf(tok::identifier, tok::kw_this))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!Tok.Next->Next)
|
if (!Tok.Next->Next)
|
||||||
|
|
|
@ -5984,6 +5984,7 @@ TEST_F(FormatTest, FormatsCasts) {
|
||||||
verifyFormat("my_int a = (my_int)(my_int)-1;");
|
verifyFormat("my_int a = (my_int)(my_int)-1;");
|
||||||
verifyFormat("my_int a = (ns::my_int)-2;");
|
verifyFormat("my_int a = (ns::my_int)-2;");
|
||||||
verifyFormat("case (my_int)ONE:");
|
verifyFormat("case (my_int)ONE:");
|
||||||
|
verifyFormat("auto x = (X)this;");
|
||||||
|
|
||||||
// FIXME: single value wrapped with paren will be treated as cast.
|
// FIXME: single value wrapped with paren will be treated as cast.
|
||||||
verifyFormat("void f(int i = (kValue)*kMask) {}");
|
verifyFormat("void f(int i = (kValue)*kMask) {}");
|
||||||
|
|
Loading…
Reference in New Issue