Add "instancetype" as a code completion result for the return type of
authorDouglas Gregor <dgregor@apple.com>
Wed, 30 Jan 2013 07:11:43 +0000 (07:11 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 30 Jan 2013 07:11:43 +0000 (07:11 +0000)
an Objective-C method. Fixes <rdar://problem/13069990>.

llvm-svn: 173905

clang/lib/Sema/SemaCodeComplete.cpp
clang/test/Index/complete-declarators.m

index 48d1b61..0bd73f3 100644 (file)
@@ -4966,6 +4966,11 @@ void Sema::CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
     Builder.AddTextChunk("sender");
     Results.AddResult(CodeCompletionResult(Builder.TakeString()));
   }
+
+  // If we're completing the return type, provide 'instancetype'.
+  if (!IsParameter) {
+    Results.AddResult(CodeCompletionResult("instancetype"));
+  }
   
   // Add various builtin type names and specifiers.
   AddOrdinaryNameResults(PCC_Type, S, *this, Results);
index 071df60..d42a3c7 100644 (file)
 }
 @end
 
+// RUN: c-index-test -code-completion-at=%s:7:4 %s | FileCheck -check-prefix=CHECK-CC0 %s
+// CHECK-CC0: NotImplemented:{TypedText IBAction}{RightParen )}{Placeholder selector}{Colon :}{LeftParen (}{Text id}{RightParen )}{Text sender} (40)
+// CHECK-CC0: macro definition:{TypedText IBAction} (70)
+// CHECK-CC0: macro definition:{TypedText IBOutlet} (70)
+// CHECK-CC0: macro definition:{TypedText IBOutletCollection}{LeftParen (}{Placeholder ClassName}{RightParen )} (70)
+// CHECK-CC0: TypedefDecl:{TypedText id} (50)
+// CHECK-CC0: NotImplemented:{TypedText in} (40)
+// CHECK-CC0: NotImplemented:{TypedText inout} (40)
+// CHECK-CC0: NotImplemented:{TypedText instancetype} (40)
+// CHECK-CC0: NotImplemented:{TypedText int} (50)
+// CHECK-CC0: NotImplemented:{TypedText long} (50)
 // RUN: c-index-test -code-completion-at=%s:7:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1-NOT: NotImplemented:{TypedText extern} (40)
 // CHECK-CC1: NotImplemented:{TypedText param1} (40)