Author: arphaman Date: Mon Mar 13 10:43:42 2017 New Revision: 297628 URL: http://llvm.org/viewvc/llvm-project?rev=297628&view=rev Log: [CodeCompletion] Format block parameter placeholders in implicit property setters using the block type information that's obtained from the property
rdar://12604235 Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp cfe/trunk/test/Index/complete-block-properties.m Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=297628&r1=297627&r2=297628&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original) +++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon Mar 13 10:43:42 2017 @@ -2288,6 +2288,15 @@ static std::string FormatFunctionParamet FunctionProtoTypeLoc BlockProto; findTypeLocationForBlockDecl(Param->getTypeSourceInfo(), Block, BlockProto, SuppressBlock); + // Try to retrieve the block type information from the property if this is a + // parameter in a setter. + if (!Block && ObjCMethodParam && + cast<ObjCMethodDecl>(Param->getDeclContext())->isPropertyAccessor()) { + if (const auto *PD = cast<ObjCMethodDecl>(Param->getDeclContext()) + ->findPropertyDecl(/*CheckOverrides=*/false)) + findTypeLocationForBlockDecl(PD->getTypeSourceInfo(), Block, BlockProto, + SuppressBlock); + } if (!Block) { // We were unable to find a FunctionProtoTypeLoc with parameter names Modified: cfe/trunk/test/Index/complete-block-properties.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-block-properties.m?rev=297628&r1=297627&r2=297628&view=diff ============================================================================== --- cfe/trunk/test/Index/complete-block-properties.m (original) +++ cfe/trunk/test/Index/complete-block-properties.m Mon Mar 13 10:43:42 2017 @@ -68,8 +68,8 @@ void noQualifierParens(NoQualifierParens // RUN: c-index-test -code-completion-at=%s:65:6 %s | FileCheck -check-prefix=CHECK-CC2 %s //CHECK-CC2: ObjCInstanceMethodDecl:{ResultType void (^)(void)}{TypedText blockProperty} (35) //CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType BarBlock}{TypedText blockProperty2} (35) -//CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlockProperty2:}{Placeholder BarBlock blockProperty2} (35) -//CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlockProperty:}{Placeholder void (^)(void)blockProperty} (35) +//CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlockProperty2:}{Placeholder ^int(int *)blockProperty2} (35) +//CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlockProperty:}{Placeholder ^(void)blockProperty} (35) @interface ClassProperties @@ -86,3 +86,9 @@ void classBlockProperties() { //CHECK-CC3: ObjCPropertyDecl:{ResultType void}{TypedText explicit}{LeftParen (}{RightParen )} (35) //CHECK-CC3-NEXT: ObjCPropertyDecl:{ResultType void (^)()}{TypedText explicit}{Equal = }{Placeholder ^(void)} (38) //CHECK-CC3-NEXT: ObjCPropertyDecl:{ResultType void}{TypedText explicitReadonly}{LeftParen (}{RightParen )} (35) + +void implicitSetterBlockPlaceholder(Test* test) { + [test setBlock: ^{}]; +} +// RUN: c-index-test -code-completion-at=%s:91:9 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlocker:}{Placeholder ^Foo(int x, Foo y, FooBlock foo)blocker} (37) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits