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:
Daniel Jasper 2015-05-19 11:18:39 +00:00
parent d90d6fb53a
commit f5e5ee6d69
2 changed files with 3 additions and 1 deletions

View File

@ -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;
}

View File

@ -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) {}");