[PATCH] D44996: [clang-format] Ensure ObjC selectors with 0 args are annotated correctly

Ben Hamilton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 30 08:06:35 PDT 2018


benhamilton added inline comments.


================
Comment at: lib/Format/TokenAnnotator.cpp:1347
+    } else if (Current.isOneOf(tok::identifier, tok::kw_new) &&
+               Current.Previous && Current.Previous->is(TT_CastRParen) &&
+               Current.Previous->MatchingParen &&
----------------
djasper wrote:
> Isn't it wrong that we detect this as a cast r_paren in the first place?
Fantastic question, I asked myself the same thing.

I tried a few variations on this (leaving it as `TT_Unknown`, making a new type, etc.) and discovered there is at least one existing place which relies on the `TT_CastRParen` type as an indicator of ObjC code. Example:

https://github.com/llvm-mirror/clang/blob/e37a191e99773959118155304ec2ed0bc0d591c2/lib/Format/TokenAnnotator.cpp#L394

I can fix those, but if I do so, I think it should be a separate diff. What do you think?


Repository:
  rC Clang

https://reviews.llvm.org/D44996





More information about the cfe-commits mailing list