Index: test/Index/code-completion.cpp
===================================================================
--- test/Index/code-completion.cpp	(revision 134453)
+++ test/Index/code-completion.cpp	(working copy)
@@ -52,10 +52,16 @@
 // CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
 // CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
 // CHECK-MEMBER: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
+// CHECK-MEMBER: Completion contexts:
+// CHECK-MEMBER: Member access
 
 // CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )}
 // CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )}
 // CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )}
+// CHECK-OVERLOAD: Completion contexts:
+// CHECK-OVERLOAD: Any type
+// CHECK-OVERLOAD: Any value
+// CHECK-OVERLOAD: Objective-C interface
 
 // RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s
 // CHECK-EXPR: NotImplemented:{TypedText int} (50)
@@ -65,3 +71,7 @@
 // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (18)
 // CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (37)
 // CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75)
+// CHECK-EXPR: Completion contexts:
+// CHECK-EXPR: Any type
+// CHECK-EXPR: Any value
+// CHECK-EXPR: Objective-C interface
Index: test/Index/complete-natural.m
===================================================================
--- test/Index/complete-natural.m	(revision 134453)
+++ test/Index/complete-natural.m	(working copy)
@@ -11,7 +11,8 @@
 // RUN: c-index-test -code-completion-at=%s:4:32 %s > %t
 // RUN: echo "DONE" >> %t
 // RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
-// CHECK-CC1-NOT: :
+// CHECK-CC1: Completion contexts:
+// CHECK-CC1: Natural language
 // CHECK-CC1: DONE
 // RUN: c-index-test -code-completion-at=%s:5:18 %s > %t
 // RUN: echo "DONE" >> %t
Index: include/clang/Sema/CodeCompleteConsumer.h
===================================================================
--- include/clang/Sema/CodeCompleteConsumer.h	(revision 134453)
+++ include/clang/Sema/CodeCompleteConsumer.h	(working copy)
@@ -235,6 +235,15 @@
     /// \brief Code completion in a parenthesized expression, which means that
     /// we may also have types here in C and Objective-C (as well as in C++).
     CCC_ParenthesizedExpression,
+    /// \brief Code completion where an Objective-C instance message is expcted.
+    CCC_ObjCInstanceMessage,
+    /// \brief Code completion where an Objective-C class message is expected. 
+    CCC_ObjCClassMessage,
+    /// \brief Code completion where a superclass of an Objective-C class is
+    /// expected.
+    CCC_ObjCSuperclass,
+    /// \brief Code completion where an Objective-C category name is expected.
+    CCC_ObjCCategoryName,
     /// \brief An unknown context, in which we are recovering from a parsing 
     /// error and don't know which completions we should give.
     CCC_Recovery
Index: include/clang-c/Index.h
===================================================================
--- include/clang-c/Index.h	(revision 134453)
+++ include/clang-c/Index.h	(working copy)
@@ -2830,6 +2830,116 @@
 };
 
 /**
+ * \brief Bits that represent the context under which completion is occurring.
+ *
+ * The enumerators in this enumeration may be bitwise-OR'd together if multiple
+ * contexts are occurring simultaneously.
+ */
+enum CXCompletionContext {
+  /**
+   * \brief The context for completions is unknown or unexposed.
+   */
+  CXCompletionContext_Unknown = 0,
+  
+  /**
+   * \brief Completions for any possible type should be included in the results.
+   */
+  CXCompletionContext_AnyType = 1 << 0,
+  
+  /**
+   * \brief Completions for any possible value (variables, function calls, etc.)
+   * should be included in the results.
+   */
+  CXCompletionContext_AnyValue = 1 << 1,
+  /**
+   * \brief Completions for values that resolve to an Objective-C object should
+   * be included in the results.
+   */
+  CXCompletionContext_ObjCObjectValue = 1 << 2,
+  /**
+   * \brief Completions for values that resolve to an Objective-C selector
+   * should be included in the results.
+   */
+  CXCompletionContext_ObjCSelectorValue = 1 << 3,
+  /**
+   * \brief Completions for values that resolve to a C++ class type should be
+   * included in the results.
+   */
+  CXCompletionContext_CXXClassTypeValue = 1 << 4,
+  
+  /**
+   * \brief Completions for fields of the member being accessed should be
+   * included in the results.
+   */
+  CXCompletionContext_MemberAccess = 1 << 5,
+  
+  /**
+   * \brief Completions for enum tags should be included in the results.
+   */
+  CXCompletionContext_EnumTag = 1 << 6,
+  /**
+   * \brief Completions for union tags should be included in the results.
+   */
+  CXCompletionContext_UnionTag = 1 << 7,
+  /**
+   * \brief Completions for struct tags should be included in the results.
+   */
+  CXCompletionContext_StructTag = 1 << 8,
+  
+  /**
+   * \brief Completions for C++ class names should be included in the results.
+   */
+  CXCompletionContext_ClassName = 1 << 9,
+  /**
+   * \brief Completions for C++ namespaces and namespace aliases should be
+   * included in the results.
+   */
+  CXCompletionContext_Namespace = 1 << 10,
+  
+  /**
+   * \brief Completions for Objective-C interfaces (classes) should be included
+   * in the results.
+   */
+  CXCompletionContext_ObjCInterface = 1 << 11,
+  /**
+   * \brief Completions for Objective-C protocols should be included in
+   * the results.
+   */
+  CXCompletionContext_ObjCProtocol = 1 << 12,
+  /**
+   * \brief Completions for Objective-C categories should be included in
+   * the results.
+   */
+  CXCompletionContext_ObjCCategory = 1 << 13,
+  /**
+   * \brief Completions for Objective-C instance methods should be included
+   * in the results.
+   */
+  CXCompletionContext_ObjCInstanceMethod = 1 << 14,
+  /**
+   * \brief Completions for Objective-C class methods should be included in
+   * the results.
+   */
+  CXCompletionContext_ObjCClassMethod = 1 << 15,
+  /**
+   * \brief Completions for Objective-C selector names should be included in
+   * the results.
+   */
+  CXCompletionContext_ObjCSelectorName = 1 << 16,
+  
+  /**
+   * \brief Completions for preprocessor macro names should be included in
+   * the results.
+   */
+  CXCompletionContext_MacroName = 1 << 17,
+  
+  /**
+   * \brief Natural language completions should be included in the results.
+   */
+  CXCompletionContext_NaturalLanguage = 1 << 18
+};
+  
+/**
  * \brief Returns a default set of code-completion options that can be
  * passed to\c clang_codeCompleteAt(). 
  */
@@ -2950,6 +3060,19 @@
                                              unsigned Index);
 
 /**
+ * \brief Determines what compeltions are appropriate for the context
+ * the given code completion.
+ * 
+ * \param Results the code completion results to query
+ *
+ * \returns the kinds of completions that are appropriate for use
+ * along with the given code completion results.
+ */
+CINDEX_LINKAGE
+unsigned long long clang_codeCompleteGetContexts(
+                                                CXCodeCompleteResults *Results);
+  
+/**
  * @}
  */
 
Index: tools/c-index-test/c-index-test.c
===================================================================
--- tools/c-index-test/c-index-test.c	(revision 134453)
+++ tools/c-index-test/c-index-test.c	(working copy)
@@ -1018,6 +1018,70 @@
   fprintf(file, "\n");
 }
 
+void print_completion_contexts(unsigned long long contexts, FILE *file) {
+  fprintf(file, "Completion contexts:\n");
+  if (contexts == CXCompletionContext_Unknown) {
+    fprintf(file, "Unknown\n");
+  }
+  if (contexts & CXCompletionContext_AnyType) {
+    fprintf(file, "Any type\n");
+  }
+  if (contexts & CXCompletionContext_AnyValue) {
+    fprintf(file, "Any value\n");
+  }
+  if (contexts & CXCompletionContext_ObjCObjectValue) {
+    fprintf(file, "Objective-C object value\n");
+  }
+  if (contexts & CXCompletionContext_ObjCSelectorValue) {
+    fprintf(file, "Objective-C selector value\n");
+  }
+  if (contexts & CXCompletionContext_CXXClassTypeValue) {
+    fprintf(file, "C++ class type value\n");
+  }
+  if (contexts & CXCompletionContext_MemberAccess) {
+    fprintf(file, "Member access\n");
+  }
+  if (contexts & CXCompletionContext_EnumTag) {
+    fprintf(file, "Enum tag\n");
+  }
+  if (contexts & CXCompletionContext_UnionTag) {
+    fprintf(file, "Union tag\n");
+  }
+  if (contexts & CXCompletionContext_StructTag) {
+    fprintf(file, "Struct tag\n");
+  }
+  if (contexts & CXCompletionContext_ClassName) {
+    fprintf(file, "Class name\n");
+  }
+  if (contexts & CXCompletionContext_Namespace) {
+    fprintf(file, "Namespace or namespace alias\n");
+  }
+  if (contexts & CXCompletionContext_ObjCInterface) {
+    fprintf(file, "Objective-C interface\n");
+  }
+  if (contexts & CXCompletionContext_ObjCProtocol) {
+    fprintf(file, "Objective-C protocol\n");
+  }
+  if (contexts & CXCompletionContext_ObjCCategory) {
+    fprintf(file, "Objective-C category\n");
+  }
+  if (contexts & CXCompletionContext_ObjCInstanceMethod) {
+    fprintf(file, "Objective-C instance method\n");
+  }
+  if (contexts & CXCompletionContext_ObjCClassMethod) {
+    fprintf(file, "Objective-C class method\n");
+  }
+  if (contexts & CXCompletionContext_ObjCSelectorName) {
+    fprintf(file, "Objective-C selector name\n");
+  }
+  if (contexts & CXCompletionContext_MacroName) {
+    fprintf(file, "Macro name\n");
+  }
+  if (contexts & CXCompletionContext_NaturalLanguage) {
+    fprintf(file, "Natural language\n");
+  }
+}
+
 int my_stricmp(const char *s1, const char *s2) {
   while (*s1 && *s2) {
     int c1 = tolower((unsigned char)*s1), c2 = tolower((unsigned char)*s2);
@@ -1112,6 +1176,10 @@
       PrintDiagnostic(diag);
       clang_disposeDiagnostic(diag);
     }
+    
+    unsigned long long contexts = clang_codeCompleteGetContexts(results);
+    print_completion_contexts(contexts, stdout);
+    
     clang_disposeCodeCompleteResults(results);
   }
   clang_disposeTranslationUnit(TU);
Index: tools/libclang/CIndexCodeCompletion.cpp
===================================================================
--- tools/libclang/CIndexCodeCompletion.cpp	(revision 134453)
+++ tools/libclang/CIndexCodeCompletion.cpp	(working copy)
@@ -22,6 +22,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/AST/Type.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Atomic.h"
@@ -235,6 +236,19 @@
   
   /// \brief Allocator used to store code completion results.
   clang::CodeCompletionAllocator CodeCompletionAllocator;
+  
+  /// \brief Context under which completion occurred.
+  enum clang::CodeCompletionContext::Kind ContextKind;
+  
+  /// \brief A bitfield representing the acceptable completions for the
+  /// current context.
+  unsigned long long Contexts;
+  
+  /// \brief Base type for member access (CCC_MemberAccess) completions.
+  clang::QualType BaseType;
+  
+  /// \brief The preferred type for the current completion context.
+  clang::QualType PreferredType;
 };
 
 /// \brief Tracks the number of code-completion result objects that are 
@@ -273,6 +287,126 @@
   
 } // end extern "C"
 
+static unsigned long long getContextsForContextKind(
+                                          enum CodeCompletionContext::Kind kind, 
+                                                    Sema &S) {
+  unsigned long long contexts = 0;
+  switch (kind) {
+    case CodeCompletionContext::CCC_OtherWithMacros: {
+      //We can allow macros here, but we don't know what else is permissible
+      //So we'll say the only thing permissible are macros
+      contexts = CXCompletionContext_MacroName;
+      break;
+    }
+    case CodeCompletionContext::CCC_TopLevel:
+    case CodeCompletionContext::CCC_ObjCIvarList:
+    case CodeCompletionContext::CCC_ClassStructUnion:
+    case CodeCompletionContext::CCC_Type: {
+      contexts = CXCompletionContext_AnyType | 
+                 CXCompletionContext_ObjCInterface;
+      break;
+    }
+    case CodeCompletionContext::CCC_Statement: {
+      contexts = CXCompletionContext_AnyType |
+                 CXCompletionContext_ObjCInterface |
+                 CXCompletionContext_AnyValue;
+      break;
+    }
+    case CodeCompletionContext::CCC_Expression: {
+      contexts = CXCompletionContext_AnyValue;
+      if (S.getLangOptions().CPlusPlus) {
+        contexts |= CXCompletionContext_AnyType |
+                    CXCompletionContext_ObjCInterface;
+      }
+      break;
+    }
+    case CodeCompletionContext::CCC_ObjCMessageReceiver: {
+      contexts = CXCompletionContext_ObjCObjectValue |
+                 CXCompletionContext_ObjCSelectorValue |
+                 CXCompletionContext_ObjCInterface;
+      if (S.getLangOptions().CPlusPlus) {
+        contexts |= CXCompletionContext_CXXClassTypeValue |
+                    CXCompletionContext_AnyType;
+      }
+      break;
+    }
+    case CodeCompletionContext::CCC_MemberAccess: {
+      contexts = CXCompletionContext_MemberAccess;
+      break;
+    }
+    case CodeCompletionContext::CCC_EnumTag: {
+      contexts = CXCompletionContext_EnumTag;
+      break;
+    }
+    case CodeCompletionContext::CCC_UnionTag: {
+      contexts = CXCompletionContext_UnionTag;
+      break;
+    }
+    case CodeCompletionContext::CCC_ClassOrStructTag: {
+      contexts = CXCompletionContext_StructTag | CXCompletionContext_ClassName;
+      break;
+    }
+    case CodeCompletionContext::CCC_ObjCProtocolName: {
+      contexts = CXCompletionContext_ObjCProtocol;
+      break;
+    }
+    case CodeCompletionContext::CCC_Namespace: {
+      contexts = CXCompletionContext_Namespace;
+      break;
+    }
+    case CodeCompletionContext::CCC_MacroNameUse: {
+      contexts = CXCompletionContext_MacroName;
+      break;
+    }
+    case CodeCompletionContext::CCC_NaturalLanguage: {
+      contexts = CXCompletionContext_NaturalLanguage;
+      break;
+    }
+    case CodeCompletionContext::CCC_SelectorName: {
+      contexts = CXCompletionContext_ObjCSelectorName;
+      break;
+    }
+    case CodeCompletionContext::CCC_ParenthesizedExpression: {
+      contexts = CXCompletionContext_AnyType |
+                 CXCompletionContext_ObjCInterface |
+                 CXCompletionContext_AnyValue;
+      break;
+    }
+    case CodeCompletionContext::CCC_ObjCInstanceMessage: {
+      contexts = CXCompletionContext_ObjCInstanceMethod;
+      break;
+    }
+    case CodeCompletionContext::CCC_ObjCClassMessage: {
+      contexts = CXCompletionContext_ObjCClassMethod;
+      break;
+    }
+    case CodeCompletionContext::CCC_ObjCSuperclass: {
+      contexts = CXCompletionContext_ObjCInterface;
+      break;
+    }
+    case CodeCompletionContext::CCC_ObjCCategoryName: {
+      contexts = CXCompletionContext_ObjCCategory;
+      break;
+    }
+    case CodeCompletionContext::CCC_Other:
+    case CodeCompletionContext::CCC_ObjCInterface:
+    case CodeCompletionContext::CCC_ObjCImplementation:
+    case CodeCompletionContext::CCC_Name:
+    case CodeCompletionContext::CCC_PotentiallyQualifiedName:
+    case CodeCompletionContext::CCC_MacroName:
+    case CodeCompletionContext::CCC_PreprocessorExpression:
+    case CodeCompletionContext::CCC_PreprocessorDirective:
+    case CodeCompletionContext::CCC_TypeQualifiers:
+    case CodeCompletionContext::CCC_Recovery: {
+      //Either we don't know what's permissible, or nothing else is
+      //So we'll just return unknown
+      contexts = CXCompletionContext_Unknown;
+      break;
+    }
+  }
+  return contexts;
+}
+
 namespace {
   class CaptureCompletionResults : public CodeCompleteConsumer {
     AllocatedCXCodeCompleteResults &AllocatedResults;
@@ -298,6 +432,16 @@
         R.CompletionString = StoredCompletion;
         StoredResults.push_back(R);
       }
+      
+      enum CodeCompletionContext::Kind kind = Context.getKind();
+      QualType baseType = Context.getBaseType();
+      QualType preferredType = Context.getPreferredType();
+      
+      AllocatedResults.ContextKind = kind;
+      AllocatedResults.BaseType = baseType;
+      AllocatedResults.PreferredType = preferredType;
+      
+      AllocatedResults.Contexts = getContextsForContextKind(kind, S);
     }
     
     virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
@@ -538,6 +682,15 @@
   return new CXStoredDiagnostic(Results->Diagnostics[Index], Results->LangOpts);
 }
 
+unsigned long long
+clang_codeCompleteGetContexts(CXCodeCompleteResults *ResultsIn) {
+  AllocatedCXCodeCompleteResults *Results
+    = static_cast<AllocatedCXCodeCompleteResults*>(ResultsIn);
+  if (!Results)
+    return 0;
+  
+  return Results->Contexts;
+}
 
 } // end extern "C"
 
Index: tools/libclang/libclang.darwin.exports
===================================================================
--- tools/libclang/libclang.darwin.exports	(revision 134453)
+++ tools/libclang/libclang.darwin.exports	(working copy)
@@ -6,6 +6,7 @@
 _clang_codeCompleteAt
 _clang_codeCompleteGetDiagnostic
 _clang_codeCompleteGetNumDiagnostics
+_clang_codeCompleteGetContexts
 _clang_constructUSR_ObjCCategory
 _clang_constructUSR_ObjCClass
 _clang_constructUSR_ObjCIvar
Index: tools/libclang/libclang.exports
===================================================================
--- tools/libclang/libclang.exports	(revision 134453)
+++ tools/libclang/libclang.exports	(working copy)
@@ -6,6 +6,7 @@
 clang_codeCompleteAt
 clang_codeCompleteGetDiagnostic
 clang_codeCompleteGetNumDiagnostics
+clang_codeCompleteGetContexts
 clang_constructUSR_ObjCCategory
 clang_constructUSR_ObjCClass
 clang_constructUSR_ObjCIvar
Index: lib/Frontend/ASTUnit.cpp
===================================================================
--- lib/Frontend/ASTUnit.cpp	(revision 134453)
+++ lib/Frontend/ASTUnit.cpp	(working copy)
@@ -182,6 +182,10 @@
     // all types are available due to functional casts.
     if (LangOpts.CPlusPlus || isa<ObjCInterfaceDecl>(ND))
       Contexts |= (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1));
+    
+    // In Objective-C, you can only be a subclass of another Objective-C class
+    if (isa<ObjCInterfaceDecl>(ND))
+      Contexts |= (1 << (CodeCompletionContext::CCC_ObjCSuperclass - 1));
 
     // Deal with tag names.
     if (isa<EnumDecl>(ND)) {
@@ -208,6 +212,8 @@
              | (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1));
   } else if (isa<ObjCProtocolDecl>(ND)) {
     Contexts = (1 << (CodeCompletionContext::CCC_ObjCProtocolName - 1));
+  } else if (isa<ObjCCategoryDecl>(ND)) {
+    Contexts = (1 << (CodeCompletionContext::CCC_ObjCCategoryName - 1));
   } else if (isa<NamespaceDecl>(ND) || isa<NamespaceAliasDecl>(ND)) {
     Contexts = (1 << (CodeCompletionContext::CCC_Namespace - 1));
    
@@ -1975,6 +1981,7 @@
   case CodeCompletionContext::CCC_Name:
   case CodeCompletionContext::CCC_PotentiallyQualifiedName:
   case CodeCompletionContext::CCC_ParenthesizedExpression:
+  case CodeCompletionContext::CCC_ObjCSuperclass:
     break;
     
   case CodeCompletionContext::CCC_EnumTag:
@@ -1993,6 +2000,9 @@
   case CodeCompletionContext::CCC_TypeQualifiers:
   case CodeCompletionContext::CCC_Other:
   case CodeCompletionContext::CCC_OtherWithMacros:
+  case CodeCompletionContext::CCC_ObjCInstanceMessage:
+  case CodeCompletionContext::CCC_ObjCClassMessage:
+  case CodeCompletionContext::CCC_ObjCCategoryName:
     // We're looking for nothing, or we're looking for names that cannot
     // be hidden.
     return;
Index: lib/Sema/SemaCodeComplete.cpp
===================================================================
--- lib/Sema/SemaCodeComplete.cpp	(revision 134453)
+++ lib/Sema/SemaCodeComplete.cpp	(working copy)
@@ -3471,10 +3471,17 @@
   }
   Results.ExitScope();
 
-  if (CodeCompleter->includeMacros())
+  //We need to make sure we're setting the right context, 
+  //so only say we include macros if the code completer says we do
+  enum CodeCompletionContext::Kind kind = CodeCompletionContext::CCC_Other;
+  if (CodeCompleter->includeMacros()) {
     AddMacroResults(PP, Results);
+    kind = CodeCompletionContext::CCC_OtherWithMacros;
+  }
+  
+  
   HandleCodeCompleteResults(this, CodeCompleter, 
-                            CodeCompletionContext::CCC_OtherWithMacros,
+                            kind,
                             Results.data(),Results.size());
 }
 
@@ -4934,7 +4941,7 @@
                                         bool AtArgumentExpression,
                                         bool IsSuper) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
-                        CodeCompletionContext::CCC_Other);
+                        CodeCompletionContext::CCC_ObjCClassMessage);
   AddClassMessageCompletions(*this, S, Receiver, SelIdents, NumSelIdents, 
                              AtArgumentExpression, IsSuper, Results);
   
@@ -4954,7 +4961,7 @@
   }
 
   HandleCodeCompleteResults(this, CodeCompleter, 
-                            CodeCompletionContext::CCC_Other,
+                            CodeCompletionContext::CCC_ObjCClassMessage,
                             Results.data(), Results.size());
 }
 
@@ -4997,7 +5004,7 @@
 
   // Build the set of methods we can see.
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
-                        CodeCompletionContext::CCC_Other);
+                        CodeCompletionContext::CCC_ObjCInstanceMessage);
   Results.EnterNewScope();
 
   // If this is a send-to-super, try to add the special "super" send 
@@ -5110,7 +5117,7 @@
   }
   
   HandleCodeCompleteResults(this, CodeCompleter, 
-                            CodeCompletionContext::CCC_Other,
+                            CodeCompletionContext::CCC_ObjCInstanceMessage,
                             Results.data(),Results.size());
 }
 
@@ -5301,8 +5308,7 @@
                       false, Results);
 
   Results.ExitScope();
-  // FIXME: Add a special context for this, use cached global completion 
-  // results.
+  // FIXME: Use cached global completion results.
   HandleCodeCompleteResults(this, CodeCompleter,
                             CodeCompletionContext::CCC_Other,
                             Results.data(),Results.size());
@@ -5311,7 +5317,7 @@
 void Sema::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
                                       SourceLocation ClassNameLoc) { 
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
-                        CodeCompletionContext::CCC_Other);
+                        CodeCompletionContext::CCC_ObjCSuperclass);
   Results.EnterNewScope();
   
   // Make sure that we ignore the class we're currently defining.
@@ -5325,10 +5331,9 @@
                       false, Results);
 
   Results.ExitScope();
-  // FIXME: Add a special context for this, use cached global completion 
-  // results.
+  // FIXME: Use cached global completion results.
   HandleCodeCompleteResults(this, CodeCompleter, 
-                            CodeCompletionContext::CCC_Other,
+                            CodeCompletionContext::CCC_ObjCSuperclass,
                             Results.data(),Results.size());
 }
 
@@ -5342,8 +5347,7 @@
                       true, Results);
 
   Results.ExitScope();
-  // FIXME: Add a special context for this, use cached global completion 
-  // results.
+  // FIXME: Use cached global completion results.
   HandleCodeCompleteResults(this, CodeCompleter, 
                             CodeCompletionContext::CCC_Other,
                             Results.data(),Results.size());
@@ -5355,7 +5359,7 @@
   typedef CodeCompletionResult Result;
   
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
-                        CodeCompletionContext::CCC_Other);
+                        CodeCompletionContext::CCC_ObjCCategoryName);
   
   // Ignore any categories we find that have already been implemented by this
   // interface.
@@ -5379,7 +5383,7 @@
   Results.ExitScope();
   
   HandleCodeCompleteResults(this, CodeCompleter, 
-                            CodeCompletionContext::CCC_Other,
+                            CodeCompletionContext::CCC_ObjCCategoryName,
                             Results.data(),Results.size());  
 }
 
@@ -5398,7 +5402,7 @@
     return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
     
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
-                        CodeCompletionContext::CCC_Other);
+                        CodeCompletionContext::CCC_ObjCCategoryName);
   
   // Add all of the categories that have have corresponding interface 
   // declarations in this class and any of its superclasses, except for
@@ -5419,7 +5423,7 @@
   Results.ExitScope();
   
   HandleCodeCompleteResults(this, CodeCompleter, 
-                            CodeCompletionContext::CCC_Other,
+                            CodeCompletionContext::CCC_ObjCCategoryName,
                             Results.data(),Results.size());  
 }
 
Index: lib/Sema/CodeCompleteConsumer.cpp
===================================================================
--- lib/Sema/CodeCompleteConsumer.cpp	(revision 134453)
+++ lib/Sema/CodeCompleteConsumer.cpp	(working copy)
@@ -64,6 +64,10 @@
   case CCC_TypeQualifiers:
   case CCC_Other:
   case CCC_OtherWithMacros:
+  case CCC_ObjCInstanceMessage:
+  case CCC_ObjCClassMessage:
+  case CCC_ObjCSuperclass:
+  case CCC_ObjCCategoryName:
     return false;
   }
   
