[cfe-commits] r90758 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/complete-objc-message.m

Douglas Gregor dgregor at apple.com
Mon Dec 7 01:54:55 PST 2009


Author: dgregor
Date: Mon Dec  7 03:54:55 2009
New Revision: 90758

URL: http://llvm.org/viewvc/llvm-project?rev=90758&view=rev
Log:
When in an Objective-C instance method, super is a valid code-completion result

Modified:
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/test/Index/complete-objc-message.m

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=90758&r1=90757&r2=90758&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon Dec  7 03:54:55 2009
@@ -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());

Modified: cfe/trunk/test/Index/complete-objc-message.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-objc-message.m?rev=90758&r1=90757&r2=90758&view=diff

==============================================================================
--- cfe/trunk/test/Index/complete-objc-message.m (original)
+++ cfe/trunk/test/Index/complete-objc-message.m Mon Dec  7 03:54:55 2009
@@ -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}





More information about the cfe-commits mailing list