When in an Objective-C instance method, super is a valid code-completion result
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90758 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index cfeefff..73e0ab0 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -1356,9 +1356,23 @@
}
void Sema::CodeCompleteOrdinaryName(Scope *S) {
+ typedef CodeCompleteConsumer::Result Result;
ResultBuilder Results(*this, &ResultBuilder::IsOrdinaryName);
unsigned NextRank = CollectLookupResults(S, Context.getTranslationUnitDecl(),
0, CurContext, Results);
+
+ Results.EnterNewScope();
+ AddTypeSpecifierResults(getLangOptions(), NextRank, Results);
+
+ if (getLangOptions().ObjC1) {
+ // Add the "super" keyword, if appropriate.
+ if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(CurContext))
+ if (Method->getClassInterface()->getSuperClass())
+ Results.MaybeAddResult(Result("super", NextRank));
+ }
+
+ Results.ExitScope();
+
if (CodeCompleter->includeMacros())
AddMacroResults(PP, NextRank, Results);
HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
diff --git a/test/Index/complete-objc-message.m b/test/Index/complete-objc-message.m
index b692986..f5827bb 100644
--- a/test/Index/complete-objc-message.m
+++ b/test/Index/complete-objc-message.m
@@ -132,3 +132,15 @@
// RUN: c-index-test -code-completion-at=%s:95:24 %s | FileCheck -check-prefix=CHECK-CC9 %s
// CHECK-CC9: ObjCInstanceMethodDecl:{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2}
// CHECK-CC9: ObjCInstanceMethodDecl:{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj}
+// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCA %s
+// CHECK-CCA: {TypedText _cmd}
+// CHECK-CCA: {TypedText self}
+// CHECK-CCA: TypedefDecl:{TypedText Class}
+// CHECK-CCA: ObjCInterfaceDecl:{TypedText Foo}
+// CHECK-CCA: ObjCCategoryDecl:{TypedText FooTestCategory}
+// CHECK-CCA: FunctionDecl:{TypedText func}{LeftParen (}{RightParen )}
+// CHECK-CCA: TypedefDecl:{TypedText id}
+// CHECK-CCA: ObjCInterfaceDecl:{TypedText MyClass}
+// CHECK-CCA: ObjCInterfaceDecl:{TypedText MySubClass}
+// CHECK-CCA: TypedefDecl:{TypedText SEL}
+// CHECK-CCA: {TypedText super}