[libclang] Indexing API: Support C++ symbols.

llvm-svn: 145058
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 8434ccf..2745ac9 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -3941,6 +3941,11 @@
 typedef void *CXIdxClientFile;
 
 /**
+ * \brief The client's data object that is associated with a semantic entity.
+ */
+typedef void *CXIdxClientEntity;
+
+/**
  * \brief The client's data object that is associated with a semantic container
  * of entities.
  */
@@ -4016,16 +4021,49 @@
   CXIdxEntity_Enum          = 13,
   CXIdxEntity_Struct        = 14,
   CXIdxEntity_Union         = 15,
-  CXIdxEntity_CXXClass      = 16
+
+  CXIdxEntity_CXXClass              = 16,
+  CXIdxEntity_CXXNamespace          = 17,
+  CXIdxEntity_CXXNamespaceAlias     = 18,
+  CXIdxEntity_CXXStaticVariable     = 19,
+  CXIdxEntity_CXXStaticMethod       = 20,
+  CXIdxEntity_CXXInstanceMethod     = 21,
+  CXIdxEntity_CXXConstructor        = 22,
+  CXIdxEntity_CXXDestructor         = 23,
+  CXIdxEntity_CXXConversionFunction = 24,
+  CXIdxEntity_CXXTypeAlias          = 25
 
 } CXIdxEntityKind;
 
+/**
+ * \brief Extra C++ template information for an entity. This can apply to:
+ * CXIdxEntity_Function
+ * CXIdxEntity_CXXClass
+ * CXIdxEntity_CXXStaticMethod
+ * CXIdxEntity_CXXInstanceMethod
+ * CXIdxEntity_CXXConstructor
+ * CXIdxEntity_CXXConversionFunction
+ * CXIdxEntity_CXXTypeAlias
+ */
+typedef enum {
+  CXIdxEntity_NonTemplate   = 0,
+  CXIdxEntity_Template      = 1,
+  CXIdxEntity_TemplatePartialSpecialization = 2,
+  CXIdxEntity_TemplateSpecialization = 3
+} CXIdxEntityCXXTemplateKind;
+
 typedef struct {
   CXIdxEntityKind kind;
+  CXIdxEntityCXXTemplateKind templateKind;
   const char *name;
   const char *USR;
+  CXCursor cursor;
 } CXIdxEntityInfo;
 
+typedef struct {
+  CXCursor cursor;
+} CXIdxContainerInfo;
+
 typedef enum {
   CXIdxAttr_Unexposed     = 0,
   CXIdxAttr_IBAction      = 1,
@@ -4050,10 +4088,11 @@
   const CXIdxEntityInfo *entityInfo;
   CXCursor cursor;
   CXIdxLoc loc;
-  CXIdxClientContainer container;
+  const CXIdxContainerInfo *container;
   int isRedeclaration;
   int isDefinition;
   int isContainer;
+  const CXIdxContainerInfo *declAsContainer;
   /**
    * \brief Whether the declaration exists in code or was created implicitly
    * by the compiler, e.g. implicit objc methods for properties.
@@ -4063,10 +4102,6 @@
   unsigned numAttributes;
 } CXIdxDeclInfo;
 
-typedef struct {
-  CXIdxClientContainer *outContainer;
-} CXIdxDeclOut;
-
 typedef enum {
   CXIdxObjCContainer_ForwardRef = 0,
   CXIdxObjCContainer_Interface = 1,
@@ -4108,6 +4143,12 @@
   const CXIdxObjCProtocolRefListInfo *protocols;
 } CXIdxObjCInterfaceDeclInfo;
 
+typedef struct {
+  const CXIdxDeclInfo *declInfo;
+  const CXIdxBaseClassInfo *const *bases;
+  unsigned numBases;
+} CXIdxCXXClassDeclInfo;
+
 /**
  * \brief Data for \see indexEntityReference callback.
  */
@@ -4150,7 +4191,7 @@
   /**
    * \brief Container context of the reference.
    */
-  CXIdxClientContainer container;
+  const CXIdxContainerInfo *container;
   CXIdxEntityRefKind kind;
 } CXIdxEntityRefInfo;
 
@@ -4194,7 +4235,7 @@
                                                  void *reserved);
 
   void (*indexDeclaration)(CXClientData client_data,
-                           const CXIdxDeclInfo *, const CXIdxDeclOut *);
+                           const CXIdxDeclInfo *);
 
   /**
    * \brief Called to index a reference of an entity.
@@ -4221,6 +4262,59 @@
 CINDEX_LINKAGE const CXIdxIBOutletCollectionAttrInfo *
 clang_index_getIBOutletCollectionAttrInfo(const CXIdxAttrInfo *);
 
+CINDEX_LINKAGE const CXIdxCXXClassDeclInfo *
+clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *);
+
+/**
+ * \brief For retrieving a custom CXIdxClientContainer attached to a
+ * container.
+ */
+CINDEX_LINKAGE CXIdxClientContainer
+clang_index_getClientContainer(const CXIdxContainerInfo *);
+
+/**
+ * \brief For setting a custom CXIdxClientContainer attached to a
+ * container.
+ */
+CINDEX_LINKAGE void
+clang_index_setClientContainer(const CXIdxContainerInfo *,CXIdxClientContainer);
+
+/**
+ * \brief For retrieving a custom CXIdxClientEntity attached to an entity.
+ */
+CINDEX_LINKAGE CXIdxClientEntity
+clang_index_getClientEntity(const CXIdxEntityInfo *);
+
+/**
+ * \brief For setting a custom CXIdxClientEntity attached to an entity.
+ */
+CINDEX_LINKAGE void
+clang_index_setClientEntity(const CXIdxEntityInfo *, CXIdxClientEntity);
+
+/**
+ * \brief An indexing action, to be applied to one or multiple translation units
+ * but not on concurrent threads. If there are threads doing indexing
+ * concurrently, they should use different CXIndexAction objects.
+ */
+typedef void *CXIndexAction;
+
+/**
+ * \brief An indexing action, to be applied to one or multiple translation units
+ * but not on concurrent threads. If there are threads doing indexing
+ * concurrently, they should use different CXIndexAction objects.
+ *
+ * \param CIdx The index object with which the index action will be associated.
+ */
+CINDEX_LINKAGE CXIndexAction clang_IndexAction_create(CXIndex CIdx);
+
+/**
+ * \brief Destroy the given index action.
+ *
+ * The index action must not be destroyed until all of the translation units
+ * created within that index action have been destroyed.
+ */
+CINDEX_LINKAGE void clang_IndexAction_dispose(CXIndexAction);
+
 typedef enum {
   /**
    * \brief Used to indicate that no special indexing options are needed.
@@ -4259,7 +4353,7 @@
  *
  * The rest of the parameters are the same as \see clang_parseTranslationUnit.
  */
-CINDEX_LINKAGE int clang_indexSourceFile(CXIndex CIdx,
+CINDEX_LINKAGE int clang_indexSourceFile(CXIndexAction,
                                          CXClientData client_data,
                                          IndexerCallbacks *index_callbacks,
                                          unsigned index_callbacks_size,
@@ -4288,11 +4382,12 @@
  * \returns If there is a failure from which the there is no recovery, returns
  * non-zero, otherwise returns 0.
  */
-CINDEX_LINKAGE int clang_indexTranslationUnit(CXTranslationUnit,
+CINDEX_LINKAGE int clang_indexTranslationUnit(CXIndexAction,
                                               CXClientData client_data,
                                               IndexerCallbacks *index_callbacks,
                                               unsigned index_callbacks_size,
-                                              unsigned index_options);
+                                              unsigned index_options,
+                                              CXTranslationUnit);
 
 /**
  * \brief Retrieve the CXIdxFile, file, line, column, and offset represented by