[llvm-branch-commits] [cfe-branch] r115445 - in /cfe/branches/Apple/whitney: lib/Sema/SemaCodeComplete.cpp test/Index/complete-blocks.m

Daniel Dunbar daniel at zuster.org
Sat Oct 2 17:04:16 PDT 2010


Author: ddunbar
Date: Sat Oct  2 19:04:16 2010
New Revision: 115445

URL: http://llvm.org/viewvc/llvm-project?rev=115445&view=rev
Log:
Merge r115444:
--
Author: Douglas Gregor <dgregor at apple.com>
Date:   Sat Oct 2 23:49:58 2010 +0000

    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.

Modified:
    cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp
    cfe/branches/Apple/whitney/test/Index/complete-blocks.m

Modified: cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp?rev=115445&r1=115444&r2=115445&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaCodeComplete.cpp Sat Oct  2 19:04:16 2010
@@ -1910,6 +1910,8 @@
   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 @@
     Result += ")";
   }
   
+  if (Param->getIdentifier())
+    Result += Param->getIdentifier()->getName();
+
   return Result;
 }
 

Modified: cfe/branches/Apple/whitney/test/Index/complete-blocks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/Index/complete-blocks.m?rev=115445&r1=115444&r2=115445&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/test/Index/complete-blocks.m (original)
+++ cfe/branches/Apple/whitney/test/Index/complete-blocks.m Sat Oct  2 19:04:16 2010
@@ -25,11 +25,21 @@
   [b method3:^int(void){ return 0; }];
 }
 
+ at interface C
+- method4:(void(^)(void))arg { };
+ at 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)





More information about the llvm-branch-commits mailing list