diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-06-02 15:02:59 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-06-02 15:02:59 +0000 |
commit | bbf4f7091f919f93fec6be59260df843e4c02613 (patch) | |
tree | 63795d4a2bb66638850ebe8c88f55f55d162ba00 /clang | |
parent | 57d8a417e7209248b14b22c80d3dec693d0731b8 (diff) | |
download | bcm5719-llvm-bbf4f7091f919f93fec6be59260df843e4c02613.tar.gz bcm5719-llvm-bbf4f7091f919f93fec6be59260df843e4c02613.zip |
ASTPrinter: Objective-C method declarations don't need a space after
the return type
rdar://32332039
llvm-svn: 304553
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 6 | ||||
-rw-r--r-- | clang/test/Misc/ast-print-objectivec.m | 15 | ||||
-rw-r--r-- | clang/test/Modules/lookup.m | 4 | ||||
-rw-r--r-- | clang/unittests/AST/DeclPrinterTest.cpp | 2 |
4 files changed, 17 insertions, 10 deletions
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index bc8a34c9365..6eeba88e403 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -1189,7 +1189,9 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) { 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(ObjCMethodDecl *OMD) { } if (OMD->param_begin() == OMD->param_end()) - Out << " " << name; + Out << name; if (OMD->isVariadic()) Out << ", ..."; diff --git a/clang/test/Misc/ast-print-objectivec.m b/clang/test/Misc/ast-print-objectivec.m index e419237bbba..cb5aacc06a4 100644 --- a/clang/test/Misc/ast-print-objectivec.m +++ b/clang/test/Misc/ast-print-objectivec.m @@ -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 diff --git a/clang/test/Modules/lookup.m b/clang/test/Modules/lookup.m index edf70639e5c..b22e41f8459 100644 --- a/clang/test/Modules/lookup.m +++ b/clang/test/Modules/lookup.m @@ -14,7 +14,7 @@ void test(id x) { // expected-note@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) diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp index e5a09a31f69..ae6d0f0dd2e 100644 --- a/clang/unittests/AST/DeclPrinterTest.cpp +++ b/clang/unittests/AST/DeclPrinterTest.cpp @@ -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) { |