r304553 - ASTPrinter: Objective-C method declarations don't need a space after

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 2 08:02:59 PDT 2017


Author: arphaman
Date: Fri Jun  2 10:02:59 2017
New Revision: 304553

URL: http://llvm.org/viewvc/llvm-project?rev=304553&view=rev
Log:
ASTPrinter: Objective-C method declarations don't need a space after
the return type

rdar://32332039

Modified:
    cfe/trunk/lib/AST/DeclPrinter.cpp
    cfe/trunk/test/Misc/ast-print-objectivec.m
    cfe/trunk/test/Modules/lookup.m
    cfe/trunk/unittests/AST/DeclPrinterTest.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=304553&r1=304552&r2=304553&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Jun  2 10:02:59 2017
@@ -1189,7 +1189,9 @@ void DeclPrinter::VisitObjCMethodDecl(Ob
   for (const auto *PI : OMD->parameters()) {
     // FIXME: selector is missing here!
     pos = name.find_first_of(':', lastPos);
-    Out << " " << name.substr(lastPos, pos - lastPos) << ':';
+    if (lastPos != 0)
+      Out << " ";
+    Out << name.substr(lastPos, pos - lastPos) << ':';
     PrintObjCMethodType(OMD->getASTContext(), 
                         PI->getObjCDeclQualifier(),
                         PI->getType());
@@ -1198,7 +1200,7 @@ void DeclPrinter::VisitObjCMethodDecl(Ob
   }
 
   if (OMD->param_begin() == OMD->param_end())
-    Out << " " << name;
+    Out << name;
 
   if (OMD->isVariadic())
       Out << ", ...";

Modified: cfe/trunk/test/Misc/ast-print-objectivec.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-objectivec.m?rev=304553&r1=304552&r2=304553&view=diff
==============================================================================
--- cfe/trunk/test/Misc/ast-print-objectivec.m (original)
+++ cfe/trunk/test/Misc/ast-print-objectivec.m Fri Jun  2 10:02:59 2017
@@ -17,25 +17,30 @@
 @implementation I
 - (void)MethP __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {}
 - (void)MethI __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {}
+
+- (void)methodWithArg:(int)x andAnotherOne:(int)y { }
 @end
 
 // CHECK: @protocol P
-// CHECK: - (void) MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)));
+// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)));
 // CHECK: @end
 
 // CHECK: @interface I : NSObject<P> 
-// CHECK: - (void) MethI __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)));
+// CHECK: - (void)MethI __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2)));
 // CHECK: @end
 
 // CHECK: @interface I(CAT)
-// CHECK: - (void) MethCAT __attribute__((availability(macos, introduced=10_1_0, deprecated=10_2)));
+// CHECK: - (void)MethCAT __attribute__((availability(macos, introduced=10_1_0, deprecated=10_2)));
 // CHECK: @end
 
 // CHECK: @implementation I
-// CHECK: - (void) MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))) {
+// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))) {
+// CHECK: }
+
+// CHECK: - (void)MethI __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))) {
 // CHECK: }
 
-// CHECK: - (void) MethI __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))) {
+// CHECK: - (void)methodWithArg:(int)x andAnotherOne:(int)y {
 // CHECK: }
 
 // CHECK: @end

Modified: cfe/trunk/test/Modules/lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup.m?rev=304553&r1=304552&r2=304553&view=diff
==============================================================================
--- cfe/trunk/test/Modules/lookup.m (original)
+++ cfe/trunk/test/Modules/lookup.m Fri Jun  2 10:02:59 2017
@@ -14,7 +14,7 @@ void test(id x) {
 // expected-note at Inputs/lookup_right.h:3{{also found}}
 }
 
-// CHECK-PRINT: - (int) method;
-// CHECK-PRINT: - (double) method
+// CHECK-PRINT: - (int)method;
+// CHECK-PRINT: - (double)method
 // CHECK-PRINT: void test(id x)
 

Modified: cfe/trunk/unittests/AST/DeclPrinterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/DeclPrinterTest.cpp?rev=304553&r1=304552&r2=304553&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/DeclPrinterTest.cpp (original)
+++ cfe/trunk/unittests/AST/DeclPrinterTest.cpp Fri Jun  2 10:02:59 2017
@@ -1228,7 +1228,7 @@ TEST(DeclPrinter, TestObjCMethod1) {
     "@end\n",
     namedDecl(hasName("A:inRange:"),
               hasDescendant(namedDecl(hasName("printThis")))).bind("id"),
-    "- (int) A:(id)anObject inRange:(long)range"));
+    "- (int)A:(id)anObject inRange:(long)range"));
 }
 
 TEST(DeclPrinter, TestObjCProtocol1) {




More information about the cfe-commits mailing list