[PATCH] D48716: [clang-format] Fix counting parameters/arguments for ObjC

Ben Hamilton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 28 08:26:35 PDT 2018


benhamilton requested changes to this revision.
benhamilton added a comment.
This revision now requires changes to proceed.

> Count selector parts also for method declarations.

What bug does this fix? Can you add a test which breaks before this change and is fixed by this change?



================
Comment at: lib/Format/FormatToken.h:247-248
+  /// If this is the first ObjC selector name in an ObjC method
+  /// definition or call, this contains the number of parts that whole selector
+  /// consist of.
   unsigned ObjCSelectorNameParts = 0;
----------------
Grammar nit: that whole selector consist of -> that the whole selector consists of



================
Comment at: lib/Format/TokenAnnotator.cpp:519
+        // FirstObjCSelectorName is set when a colon is found. This does
+        // not work, however, when method has no parameters.
+        // Here, we set FirstObjCSelectorName when the end of the expression is
----------------
Grammar nit-pick: when method -> when the method



================
Comment at: lib/Format/TokenAnnotator.cpp:520
+        // not work, however, when method has no parameters.
+        // Here, we set FirstObjCSelectorName when the end of the expression is
+        // reached, in case it was not set already.
----------------
expression -> method call



================
Comment at: lib/Format/TokenAnnotator.cpp:627
   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
+    // For ObjC methods number of parameters is calculated differently as
+    // method declarations have different structure (parameters are not inside
----------------
Grammar nit-pick: methods number -> methods, the number



================
Comment at: lib/Format/TokenAnnotator.cpp:628
+    // For ObjC methods number of parameters is calculated differently as
+    // method declarations have different structure (parameters are not inside
+    // parenthesis scope).
----------------
Grammar nit-picks:

* have different structure -> have a different structure
* parameters are not -> the parameters are not



================
Comment at: lib/Format/TokenAnnotator.cpp:628-629
+    // For ObjC methods number of parameters is calculated differently as
+    // method declarations have different structure (parameters are not inside
+    // parenthesis scope).
     if (Current->is(tok::l_brace) && Current->BlockKind == BK_Block)
----------------
benhamilton wrote:
> Grammar nit-picks:
> 
> * have different structure -> have a different structure
> * parameters are not -> the parameters are not
> 
Why does parenthesis scope matter here? `updateParameterCount()` is called from `parseSquare()`.

I'm not sure what the goal of this change is.



Repository:
  rC Clang

https://reviews.llvm.org/D48716





More information about the cfe-commits mailing list