[PATCH] D43906: [clang-format] Improve detection of Objective-C block types

Ben Hamilton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 7 07:54:12 PST 2018

benhamilton added inline comments.

Comment at: lib/Format/TokenAnnotator.cpp:152
+      const FormatToken *Next = CurrentToken->getNextNonComment();
+      int ParenDepth = 1;
+      // Handle nested parens in case we have an array of blocks with
djasper wrote:
> No. Don't implement yet another parenthesis counting. This function already iterates over all tokens until the closing paren. Just store a pointer to the caret here and mark it (or unmark it) when encountering the closing brace (line 271). There is already very similar logic there to set TT_FunctionTypeLParen (which is actually doing the exact same parsing now that I think of it).
Oh! Yes, re-using the logic for `TT_FunctionTypeLParen` is clearly the right thing to do, since it has exactly the same syntax (just `*` or `&` instead of `^`).

Done, code is much cleaner now.

  rC Clang


More information about the cfe-commits mailing list