зеркало из https://github.com/microsoft/clang-1.git
Don't format sizeof/alignof as function types.
Before: A<sizeof (*x)> a; After: A<sizeof(*x)> a; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181764 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
028d59c9e5
Коммит
7424d79613
|
@ -173,7 +173,9 @@ private:
|
|||
}
|
||||
if (CurrentToken->isOneOf(tok::r_square, tok::r_brace))
|
||||
return false;
|
||||
if (CurrentToken->Parent->Type == TT_PointerOrReference &&
|
||||
if (Left->Parent &&
|
||||
!Left->Parent->isOneOf(tok::kw_sizeof, tok::kw_alignof) &&
|
||||
CurrentToken->Parent->Type == TT_PointerOrReference &&
|
||||
CurrentToken->Parent->Parent->isOneOf(tok::l_paren, tok::coloncolon))
|
||||
Left->DefinesFunctionType = true;
|
||||
updateParameterCount(Left, CurrentToken);
|
||||
|
|
|
@ -2790,6 +2790,10 @@ TEST_F(FormatTest, FormatsFunctionTypes) {
|
|||
|
||||
verifyGoogleFormat("A<void*(int*, SomeType*)>;");
|
||||
verifyGoogleFormat("void* (*a)(int);");
|
||||
|
||||
// Other constructs can look like function types:
|
||||
verifyFormat("A<sizeof(*x)> a;");
|
||||
verifyFormat("A<alignof(*x)> a;");
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, BreaksLongDeclarations) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче