[PATCH] D17922: [clang-format] Don't add a space before Obj-C selector methods that are also clang-format keywords

2020-11-16 Thread Keith Smiley via Phabricator via cfe-commits
keith commandeered this revision.
keith added a reviewer: ksuther.
keith added a comment.

Note the test case shown here passes on master, so we can drop this


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17922/new/

https://reviews.llvm.org/D17922

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17922: [clang-format] Don't add a space before Obj-C selector methods that are also clang-format keywords

2016-03-06 Thread Kent Sutherland via cfe-commits
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)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 
   return false;
   }


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7433,6 +7433,7 @@
" y:(id)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 
   return false;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits