diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-10-02 23:49:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-10-02 23:49:58 +0000 |
commit | af25cfaae01ecd3317608a8305200d26722fb771 (patch) | |
tree | 49f5b5a5490a71477cd78b9288055ae9a32f4c42 | |
parent | f717f3ae61394ed7d76e1c60b9d2d825196fb29b (diff) | |
download | bcm5719-llvm-af25cfaae01ecd3317608a8305200d26722fb771.tar.gz bcm5719-llvm-af25cfaae01ecd3317608a8305200d26722fb771.zip |
When providing a block literal as a code completion for a
function/method argument, include the parameter name and always
include parentheses (even for zero-parameter blocks). Otherwise, the
block literal placeholder '^' can look very weird.
llvm-svn: 115444
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 5 | ||||
-rw-r--r-- | clang/test/Index/complete-blocks.m | 20 |
2 files changed, 20 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 64a96dbff7a..ae82ceb334a 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -1910,6 +1910,8 @@ static std::string FormatFunctionParameter(ASTContext &Context, if (Block->getNumArgs() == 0) { if (Block->getTypePtr()->isVariadic()) Result += "(...)"; + else + Result += "(void)"; } else { Result += "("; for (unsigned I = 0, N = Block->getNumArgs(); I != N; ++I) { @@ -1923,6 +1925,9 @@ static std::string FormatFunctionParameter(ASTContext &Context, Result += ")"; } + if (Param->getIdentifier()) + Result += Param->getIdentifier()->getName(); + return Result; } diff --git a/clang/test/Index/complete-blocks.m b/clang/test/Index/complete-blocks.m index 281b5e63f0b..61e363e3752 100644 --- a/clang/test/Index/complete-blocks.m +++ b/clang/test/Index/complete-blocks.m @@ -25,11 +25,21 @@ void test_B(B *b) { [b method3:^int(void){ return 0; }]; } +@interface C +- method4:(void(^)(void))arg { }; +@end + +void test_C(C *c) { + [c method4:^{}]; +} + // RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)}{RightParen )} (50) -// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)}{RightParen )} (50) +// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50) +// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)b}{RightParen )} (50) // RUN: c-index-test -code-completion-at=%s:17:6 %s | FileCheck -check-prefix=CHECK-CC2 %s -// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2:}{Placeholder ^(float f, double d)} (20) -// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method:}{Placeholder ^int(int x, int y)} (20) +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2:}{Placeholder ^(float f, double d)b} (20) +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method:}{Placeholder ^int(int x, int y)b} (20) // RUN: c-index-test -code-completion-at=%s:25:6 %s | FileCheck -check-prefix=CHECK-CC3 %s -// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText method3:}{Placeholder ^int} (20) +// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText method3:}{Placeholder ^int(void)b} (20) +// RUN: c-index-test -code-completion-at=%s:33:6 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType id}{TypedText method4:}{Placeholder ^(void)arg} (20) |