[PATCH] D41448: Fix counting parameters/arguments for ObjC.

Jacek Olesiak via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 20 06:47:09 PST 2017


jolesiak created this revision.
jolesiak added a reviewer: krasimir.
Herald added a subscriber: klimek.

[clang-format] Fix ParameterCount for ObjC.


Repository:
  rC Clang

https://reviews.llvm.org/D41448

Files:
  lib/Format/TokenAnnotator.cpp


Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -414,6 +414,7 @@
                           TT_DesignatedInitializerLSquare)) {
           Left->Type = TT_ObjCMethodExpr;
           StartsObjCMethodExpr = true;
+          Left->ParameterCount = 0;
           Contexts.back().ColonIsObjCMethodExpr = true;
           if (Parent && Parent->is(tok::r_paren))
             Parent->Type = TT_CastRParen;
@@ -486,7 +487,11 @@
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
     if (Current->is(tok::l_brace) && Current->BlockKind == BK_Block)
       ++Left->BlockParameterCount;
-    if (Current->is(tok::comma)) {
+
+    if (Left->Type == TT_ObjCMethodExpr) {
+      if (Current->is(tok::colon))
+        ++Left->ParameterCount;
+    } else if (Current->is(tok::comma)) {
       ++Left->ParameterCount;
       if (!Left->Role)
         Left->Role.reset(new CommaSeparatedList(Style));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41448.127714.patch
Type: text/x-patch
Size: 1033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171220/83644dfc/attachment.bin>


More information about the cfe-commits mailing list