зеркало из https://github.com/microsoft/clang-1.git
More precisely recognize ObjC method declarations.
Otherwise, +/- and the beginning of constants can be recognized incorrectly. Before: #define A - 1 After: #define A -1 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177725 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
b2cc521590
Коммит
b5985420d5
|
@ -313,9 +313,11 @@ private:
|
|||
switch (Tok->FormatTok.Tok.getKind()) {
|
||||
case tok::plus:
|
||||
case tok::minus:
|
||||
// At the start of the line, +/- specific ObjectiveC method
|
||||
// declarations.
|
||||
if (Tok->Parent == NULL)
|
||||
// At the start of the line, +/- specify ObjectiveC method declarations.
|
||||
if (Tok->Children.empty() || Tok->Children[0].Children.empty())
|
||||
break; // Can't be an ObjectiveC method declaration.
|
||||
if (Tok->Parent == NULL && (Tok->Children[0].is(tok::l_paren) ||
|
||||
Tok->Children[0].Children[0].is(tok::colon)))
|
||||
Tok->Type = TT_ObjCMethodSpecifier;
|
||||
break;
|
||||
case tok::colon:
|
||||
|
|
|
@ -2067,6 +2067,8 @@ TEST_F(FormatTest, UnderstandsUnaryOperators) {
|
|||
"case -1:\n"
|
||||
" break;\n"
|
||||
"}");
|
||||
verifyFormat("#define X -1");
|
||||
verifyFormat("#define X -kConstant");
|
||||
|
||||
verifyFormat("const NSPoint kBrowserFrameViewPatternOffset = { -5, +3 };");
|
||||
verifyFormat("const NSPoint kBrowserFrameViewPatternOffset = { +5, -3 };");
|
||||
|
|
Загрузка…
Ссылка в новой задаче