ksuther created this revision. ksuther added a reviewer: djasper. ksuther added a subscriber: cfe-commits. Herald added a subscriber: klimek.
The following Obj-C methods will get formatted with an extra space between the right paren and the name: `- (void)delete:(id)sender` `- (void)export:(id)sender` So they'll incorrectly appear as: `- (void) delete:(id)sender` `- (void) export:(id)sender` The fix is to check if the token is a TT_SelectorName instead of tok::identifier. That way keywords recognized by clang-format still get treated as an Obj-C method name (because they're both a TT_SelectorName and tok::delete type). http://reviews.llvm.org/D17922 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -7433,6 +7433,7 @@ " y:(id<yyyyyyyyyyyyyyyyyyyy>)y\n" " NS_DESIGNATED_INITIALIZER;", getLLVMStyleWithColumns(60)); + verifyFormat("- (void)delete:(id)sender\n"); // Continuation indent width should win over aligning colons if the function // name is long. Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2077,7 +2077,7 @@ if (Line.Type == LT_ObjCMethodDecl) { if (Left.is(TT_ObjCMethodSpecifier)) return true; - if (Left.is(tok::r_paren) && Right.is(tok::identifier)) + if (Left.is(tok::r_paren) && Right.is(TT_SelectorName)) // Don't space between ')' and <id> return false; }
Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -7433,6 +7433,7 @@ " y:(id<yyyyyyyyyyyyyyyyyyyy>)y\n" " NS_DESIGNATED_INITIALIZER;", getLLVMStyleWithColumns(60)); + verifyFormat("- (void)delete:(id)sender\n"); // Continuation indent width should win over aligning colons if the function // name is long. Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2077,7 +2077,7 @@ if (Line.Type == LT_ObjCMethodDecl) { if (Left.is(TT_ObjCMethodSpecifier)) return true; - if (Left.is(tok::r_paren) && Right.is(tok::identifier)) + if (Left.is(tok::r_paren) && Right.is(TT_SelectorName)) // Don't space between ')' and <id> return false; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits