From: Daniel Jasper Date: Thu, 23 Apr 2015 13:58:40 +0000 (+0000) Subject: clang-format: Properly detect variable declarations with ObjC. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=418836a44a07251898d0c8e85646c081fd4ba78e;p=clang clang-format: Properly detect variable declarations with ObjC. Before: LoooooooooooooooooooooooooooooooooooooooongType LoooooooooooooooooooooooooooooooooooooongVariable([A a]); After: LoooooooooooooooooooooooooooooooooooooooongType LoooooooooooooooooooooooooooooooooooooongVariable([A a]); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235599 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index c6ffd8a977..e52650be07 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1400,7 +1400,8 @@ static bool isFunctionDeclarationName(const FormatToken &Current) { if (Tok->is(tok::kw_const) || Tok->isSimpleTypeSpecifier() || Tok->isOneOf(TT_PointerOrReference, TT_StartOfName)) return true; - if (Tok->isOneOf(tok::l_brace, tok::string_literal) || Tok->Tok.isLiteral()) + if (Tok->isOneOf(tok::l_brace, tok::string_literal, TT_ObjCMethodExpr) || + Tok->Tok.isLiteral()) return false; } return false; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 0f2545105e..6e2b950523 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5698,6 +5698,8 @@ TEST_F(FormatTest, BreaksLongVariableDeclarations) { " LoooooooooooooooooooooooooooooooooooooooongVariable(a);"); verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" " LoooooooooooooooooooooooooooooooooooooooongVariable({});"); + verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" + " LoooooooooooooooooooooooooooooooooooooongVariable([A a]);"); } TEST_F(FormatTest, BreaksLongDeclarations) {