forked from OSchip/llvm-project
clang-format: Correctly detect casts to qualified types.
Before: ns::E f() { return (ns::E) - 1; } After: ns::E f() { return (ns::E)-1; } This fixes llvm.org/PR23503. llvm-svn: 237684
This commit is contained in:
parent
d90d6fb53a
commit
f5e5ee6d69
|
@ -1082,7 +1082,8 @@ private:
|
|||
}
|
||||
|
||||
for (; Prev != Tok.MatchingParen; Prev = Prev->Previous) {
|
||||
if (!Prev || !Prev->isOneOf(tok::kw_const, tok::identifier)) {
|
||||
if (!Prev ||
|
||||
!Prev->isOneOf(tok::kw_const, tok::identifier, tok::coloncolon)) {
|
||||
IsCast = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -5765,6 +5765,7 @@ TEST_F(FormatTest, FormatsCasts) {
|
|||
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;");
|
||||
verifyFormat("my_int a = (ns::my_int)-2;");
|
||||
|
||||
// FIXME: single value wrapped with paren will be treated as cast.
|
||||
verifyFormat("void f(int i = (kValue)*kMask) {}");
|
||||
|
|
Loading…
Reference in New Issue