[cfe-commits] r145058 - in /cfe/trunk: include/clang-c/Index.h tools/c-index-test/c-index-test.c tools/libclang/CXCursor.cpp tools/libclang/CXCursor.h tools/libclang/IndexBody.cpp tools/libclang/IndexDecl.cpp tools/libclang/Indexing.cpp tools/libclang/IndexingContext.cpp tools/libclang/IndexingContext.h tools/libclang/libclang.exports
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Nov 21 23:24:51 PST 2011
Author: akirtzidis
Date: Tue Nov 22 01:24:51 2011
New Revision: 145058
URL: http://llvm.org/viewvc/llvm-project?rev=145058&view=rev
Log:
[libclang] Indexing API: Support C++ symbols.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CXCursor.cpp
cfe/trunk/tools/libclang/CXCursor.h
cfe/trunk/tools/libclang/IndexBody.cpp
cfe/trunk/tools/libclang/IndexDecl.cpp
cfe/trunk/tools/libclang/Indexing.cpp
cfe/trunk/tools/libclang/IndexingContext.cpp
cfe/trunk/tools/libclang/IndexingContext.h
cfe/trunk/tools/libclang/libclang.exports
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Nov 22 01:24:51 2011
@@ -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
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Nov 22 01:24:51 2011
@@ -1609,7 +1609,9 @@
return (CXIdxClientContainer)newStr;
}
-static void printCXIndexContainer(CXIdxClientContainer container) {
+static void printCXIndexContainer(const CXIdxContainerInfo *info) {
+ CXIdxClientContainer container;
+ container = clang_index_getClientContainer(info);
if (!container)
printf("[<<NULL>>]");
else
@@ -1635,6 +1637,27 @@
case CXIdxEntity_Struct: return "struct";
case CXIdxEntity_Union: return "union";
case CXIdxEntity_CXXClass: return "c++-class";
+ case CXIdxEntity_CXXNamespace: return "namespace";
+ case CXIdxEntity_CXXNamespaceAlias: return "namespace-alias";
+ case CXIdxEntity_CXXStaticVariable: return "c++-static-var";
+ case CXIdxEntity_CXXStaticMethod: return "c++-static-method";
+ case CXIdxEntity_CXXInstanceMethod: return "c++-instance-method";
+ case CXIdxEntity_CXXConstructor: return "constructor";
+ case CXIdxEntity_CXXDestructor: return "destructor";
+ case CXIdxEntity_CXXConversionFunction: return "conversion-func";
+ case CXIdxEntity_CXXTypeAlias: return "type-alias";
+ }
+ assert(0 && "Garbage entity kind");
+ return 0;
+}
+
+static const char *getEntityTemplateKindString(CXIdxEntityCXXTemplateKind kind) {
+ switch (kind) {
+ case CXIdxEntity_NonTemplate: return "";
+ case CXIdxEntity_Template: return "-template";
+ case CXIdxEntity_TemplatePartialSpecialization:
+ return "-template-partial-spec";
+ case CXIdxEntity_TemplateSpecialization: return "-template-spec";
}
assert(0 && "Garbage entity kind");
return 0;
@@ -1657,7 +1680,8 @@
if (!name)
name = "<anon-tag>";
- printf("%s: kind: %s", cb, getEntityKindString(info->kind));
+ printf("%s: kind: %s%s", cb, getEntityKindString(info->kind),
+ getEntityTemplateKindString(info->templateKind));
printf(" | name: %s", name);
printf(" | USR: %s", info->USR);
}
@@ -1735,8 +1759,7 @@
}
static void index_indexDeclaration(CXClientData client_data,
- const CXIdxDeclInfo *info,
- const CXIdxDeclOut *outData) {
+ const CXIdxDeclInfo *info) {
IndexData *index_data;
const CXIdxObjCCategoryDeclInfo *CatInfo;
const CXIdxObjCInterfaceDeclInfo *InterInfo;
@@ -1804,8 +1827,9 @@
printProtocolList(ProtoInfo, client_data);
}
- if (outData->outContainer)
- *outData->outContainer = makeClientContainer(info->entityInfo, info->loc);
+ if (info->declAsContainer)
+ clang_index_setClientContainer(info->declAsContainer,
+ makeClientContainer(info->entityInfo, info->loc));
}
static void index_indexEntityReference(CXClientData client_data,
@@ -1839,7 +1863,8 @@
static int index_file(int argc, const char **argv) {
const char *check_prefix;
- CXIndex CIdx;
+ CXIndex Idx;
+ CXIndexAction idxAction;
IndexData index_data;
unsigned index_opts;
int result;
@@ -1858,7 +1883,14 @@
return -1;
}
- CIdx = clang_createIndex(0, 1);
+ if (!(Idx = clang_createIndex(/* excludeDeclsFromPCH */ 1,
+ /* displayDiagnosics=*/1))) {
+ fprintf(stderr, "Could not create Index\n");
+ return 1;
+ }
+ idxAction = 0;
+ result = 1;
+
index_data.check_prefix = check_prefix;
index_data.first_check_printed = 0;
index_data.fail_for_error = 0;
@@ -1867,17 +1899,21 @@
if (getenv("CINDEXTEST_SUPPRESSREFS"))
index_opts |= CXIndexOpt_SuppressRedundantRefs;
- result = clang_indexSourceFile(CIdx, &index_data,
+ idxAction = clang_IndexAction_create(Idx);
+ result = clang_indexSourceFile(idxAction, &index_data,
&IndexCB,sizeof(IndexCB), index_opts,
0, argv, argc, 0, 0, 0, 0);
if (index_data.fail_for_error)
- return -1;
+ result = -1;
+ clang_IndexAction_dispose(idxAction);
+ clang_disposeIndex(Idx);
return result;
}
static int index_tu(int argc, const char **argv) {
CXIndex Idx;
+ CXIndexAction idxAction;
CXTranslationUnit TU;
const char *check_prefix;
IndexData index_data;
@@ -1903,9 +1939,11 @@
fprintf(stderr, "Could not create Index\n");
return 1;
}
+ idxAction = 0;
+ result = 1;
if (!CreateTranslationUnit(Idx, argv[0], &TU))
- return 1;
+ goto finished;
index_data.check_prefix = check_prefix;
index_data.first_check_printed = 0;
@@ -1914,13 +1952,18 @@
index_opts = 0;
if (getenv("CINDEXTEST_SUPPRESSREFS"))
index_opts |= CXIndexOpt_SuppressRedundantRefs;
-
- result = clang_indexTranslationUnit(TU, &index_data,
+
+ idxAction = clang_IndexAction_create(Idx);
+ result = clang_indexTranslationUnit(idxAction, &index_data,
&IndexCB,sizeof(IndexCB),
- index_opts);
+ index_opts, TU);
if (index_data.fail_for_error)
- return -1;
+ goto finished;
+ finished:
+ clang_IndexAction_dispose(idxAction);
+ clang_disposeIndex(Idx);
+
return result;
}
Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Tue Nov 22 01:24:51 2011
@@ -588,9 +588,9 @@
reinterpret_cast<uintptr_t>(C.data[1])));
}
-CXCursor cxcursor::MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B,
+CXCursor cxcursor::MakeCursorCXXBaseSpecifier(const CXXBaseSpecifier *B,
CXTranslationUnit TU){
- CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { B, 0, TU } };
+ CXCursor C = { CXCursor_CXXBaseSpecifier, 0, { (void*)B, 0, TU } };
return C;
}
Modified: cfe/trunk/tools/libclang/CXCursor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.h?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.h (original)
+++ cfe/trunk/tools/libclang/CXCursor.h Tue Nov 22 01:24:51 2011
@@ -120,7 +120,7 @@
std::pair<FieldDecl *, SourceLocation> getCursorMemberRef(CXCursor C);
/// \brief Create a CXX base specifier cursor.
-CXCursor MakeCursorCXXBaseSpecifier(CXXBaseSpecifier *B,
+CXCursor MakeCursorCXXBaseSpecifier(const CXXBaseSpecifier *B,
CXTranslationUnit TU);
/// \brief Unpack a CXXBaseSpecifier cursor into a CXXBaseSpecifier.
Modified: cfe/trunk/tools/libclang/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexBody.cpp?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexBody.cpp (original)
+++ cfe/trunk/tools/libclang/IndexBody.cpp Tue Nov 22 01:24:51 2011
@@ -80,6 +80,12 @@
SaveAndRestore<bool> InPseudo(InPseudoObject, true);
return base::TraversePseudoObjectExpr(E);
}
+
+ bool VisitCXXConstructExpr(CXXConstructExpr *E) {
+ IndexCtx.handleReference(E->getConstructor(), E->getLocation(), 0,
+ ParentDC, E);
+ return true;
+ }
};
} // anonymous namespace
Modified: cfe/trunk/tools/libclang/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexDecl.cpp?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexDecl.cpp (original)
+++ cfe/trunk/tools/libclang/IndexDecl.cpp Tue Nov 22 01:24:51 2011
@@ -52,8 +52,8 @@
return true;
}
- bool VisitTypedefDecl(TypedefDecl *D) {
- IndexCtx.handleTypedef(D);
+ bool VisitTypedefDecl(TypedefNameDecl *D) {
+ IndexCtx.handleTypedefName(D);
IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
return true;
}
@@ -182,7 +182,32 @@
if (MD->isSynthesized())
IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation());
}
+ return true;
+ }
+
+ bool VisitClassTemplateDecl(ClassTemplateDecl *D) {
+ IndexCtx.handleClassTemplate(D);
+ if (D->isThisDeclarationADefinition())
+ IndexCtx.indexDeclContext(D->getTemplatedDecl());
+ return true;
+ }
+
+ bool VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
+ IndexCtx.handleFunctionTemplate(D);
+ FunctionDecl *FD = D->getTemplatedDecl();
+ IndexCtx.indexTypeSourceInfo(FD->getTypeSourceInfo(), D);
+ if (FD->isThisDeclarationADefinition()) {
+ const Stmt *Body = FD->getBody();
+ if (Body) {
+ IndexCtx.indexBody(Body, FD);
+ }
+ }
+ return true;
+ }
+ bool VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
+ IndexCtx.handleTypeAliasTemplate(D);
+ IndexCtx.indexTypeSourceInfo(D->getTemplatedDecl()->getTypeSourceInfo(), D);
return true;
}
};
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Tue Nov 22 01:24:51 2011
@@ -183,7 +183,7 @@
//===----------------------------------------------------------------------===//
struct IndexSourceFileInfo {
- CXIndex CIdx;
+ CXIndexAction idxAction;
CXClientData client_data;
IndexerCallbacks *index_callbacks;
unsigned index_callbacks_size;
@@ -213,7 +213,7 @@
static void clang_indexSourceFile_Impl(void *UserData) {
IndexSourceFileInfo *ITUI =
static_cast<IndexSourceFileInfo*>(UserData);
- CXIndex CIdx = ITUI->CIdx;
+ CXIndex CIdx = (CXIndex)ITUI->idxAction;
CXClientData client_data = ITUI->client_data;
IndexerCallbacks *client_index_callbacks = ITUI->index_callbacks;
unsigned index_callbacks_size = ITUI->index_callbacks_size;
@@ -352,11 +352,12 @@
namespace {
struct IndexTranslationUnitInfo {
- CXTranslationUnit TU;
+ CXIndexAction idxAction;
CXClientData client_data;
IndexerCallbacks *index_callbacks;
unsigned index_callbacks_size;
unsigned index_options;
+ CXTranslationUnit TU;
int result;
};
@@ -560,24 +561,76 @@
return 0;
}
-int clang_indexSourceFile(CXIndex CIdx,
- CXClientData client_data,
- IndexerCallbacks *index_callbacks,
- unsigned index_callbacks_size,
- unsigned index_options,
- const char *source_filename,
- const char * const *command_line_args,
- int num_command_line_args,
- struct CXUnsavedFile *unsaved_files,
- unsigned num_unsaved_files,
- CXTranslationUnit *out_TU,
- unsigned TU_options) {
-
- IndexSourceFileInfo ITUI = { CIdx, client_data, index_callbacks,
- index_callbacks_size, index_options,
- source_filename, command_line_args,
- num_command_line_args, unsaved_files,
- num_unsaved_files, out_TU, TU_options, 0 };
+const CXIdxCXXClassDeclInfo *
+clang_index_getCXXClassDeclInfo(const CXIdxDeclInfo *DInfo) {
+ if (!DInfo)
+ return 0;
+
+ const DeclInfo *DI = static_cast<const DeclInfo *>(DInfo);
+ if (const CXXClassDeclInfo *ClassInfo = dyn_cast<CXXClassDeclInfo>(DI))
+ return &ClassInfo->CXXClassInfo;
+
+ return 0;
+}
+
+CXIdxClientContainer
+clang_index_getClientContainer(const CXIdxContainerInfo *info) {
+ if (!info)
+ return 0;
+ ContainerInfo *Container = (ContainerInfo*)info;
+ return Container->IndexCtx->getClientContainerForDC(Container->DC);
+}
+
+void clang_index_setClientContainer(const CXIdxContainerInfo *info,
+ CXIdxClientContainer client) {
+ if (!info)
+ return;
+ ContainerInfo *Container = (ContainerInfo*)info;
+ Container->IndexCtx->addContainerInMap(Container->DC, client);
+}
+
+CXIdxClientEntity clang_index_getClientEntity(const CXIdxEntityInfo *info) {
+ if (!info)
+ return 0;
+ EntityInfo *Entity = (EntityInfo*)info;
+ return Entity->IndexCtx->getClientEntity(Entity->Dcl);
+}
+
+void clang_index_setClientEntity(const CXIdxEntityInfo *info,
+ CXIdxClientEntity client) {
+ if (!info)
+ return;
+ EntityInfo *Entity = (EntityInfo*)info;
+ Entity->IndexCtx->setClientEntity(Entity->Dcl, client);
+}
+
+CXIndexAction clang_IndexAction_create(CXIndex CIdx) {
+ // For now, CXIndexAction is featureless.
+ return CIdx;
+}
+
+void clang_IndexAction_dispose(CXIndexAction idxAction) {
+ // For now, CXIndexAction is featureless.
+}
+
+int clang_indexSourceFile(CXIndexAction idxAction,
+ CXClientData client_data,
+ IndexerCallbacks *index_callbacks,
+ unsigned index_callbacks_size,
+ unsigned index_options,
+ const char *source_filename,
+ const char * const *command_line_args,
+ int num_command_line_args,
+ struct CXUnsavedFile *unsaved_files,
+ unsigned num_unsaved_files,
+ CXTranslationUnit *out_TU,
+ unsigned TU_options) {
+
+ IndexSourceFileInfo ITUI = { idxAction, client_data, index_callbacks,
+ index_callbacks_size, index_options,
+ source_filename, command_line_args,
+ num_command_line_args, unsaved_files,
+ num_unsaved_files, out_TU, TU_options, 0 };
if (getenv("LIBCLANG_NOTHREADS")) {
clang_indexSourceFile_Impl(&ITUI);
@@ -616,14 +669,16 @@
return ITUI.result;
}
-int clang_indexTranslationUnit(CXTranslationUnit TU,
+int clang_indexTranslationUnit(CXIndexAction idxAction,
CXClientData client_data,
IndexerCallbacks *index_callbacks,
unsigned index_callbacks_size,
- unsigned index_options) {
+ unsigned index_options,
+ CXTranslationUnit TU) {
- IndexTranslationUnitInfo ITUI = { TU, client_data, index_callbacks,
- index_callbacks_size, index_options, 0 };
+ IndexTranslationUnitInfo ITUI = { idxAction, client_data, index_callbacks,
+ index_callbacks_size, index_options, TU,
+ 0 };
if (getenv("LIBCLANG_NOTHREADS")) {
clang_indexTranslationUnit_Impl(&ITUI);
Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Tue Nov 22 01:24:51 2011
@@ -12,7 +12,7 @@
#include "CIndexDiagnostic.h"
#include "clang/Frontend/ASTUnit.h"
-#include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
using namespace clang;
@@ -28,7 +28,7 @@
I = ProtList.begin(), E = ProtList.end(); I != E; ++I, ++LI) {
SourceLocation Loc = *LI;
ObjCProtocolDecl *PD = *I;
- ProtEntities.push_back(CXIdxEntityInfo());
+ ProtEntities.push_back(EntityInfo());
IdxCtx.getEntityInfo(PD, ProtEntities.back(), SA);
CXIdxObjCProtocolRefInfo ProtInfo = { 0,
MakeCursorObjCProtocolRef(PD, Loc, IdxCtx.CXTU),
@@ -80,8 +80,8 @@
QualType Ty = IBAttr->getInterface();
if (const ObjCInterfaceType *InterTy = Ty->getAs<ObjCInterfaceType>()) {
if (const ObjCInterfaceDecl *InterD = InterTy->getInterface()) {
- IdxCtx.getEntityInfo(InterD, IBInfo.CXClassInfo, SA);
- IBInfo.IBCollInfo.objcClass = &IBInfo.CXClassInfo;
+ IdxCtx.getEntityInfo(InterD, IBInfo.ClassInfo, SA);
+ IBInfo.IBCollInfo.objcClass = &IBInfo.ClassInfo;
IBInfo.IBCollInfo.classCursor = MakeCursorObjCClassRef(InterD,
IBAttr->getInterfaceLoc(), IdxCtx.CXTU);
}
@@ -92,6 +92,32 @@
CXAttrs.push_back(&Attrs[i]);
}
+IndexingContext::CXXBasesListInfo::CXXBasesListInfo(const CXXRecordDecl *D,
+ IndexingContext &IdxCtx,
+ IndexingContext::StrAdapter &SA) {
+ for (CXXRecordDecl::base_class_const_iterator
+ I = D->bases_begin(), E = D->bases_end(); I != E; ++I) {
+ const CXXBaseSpecifier &Base = *I;
+ BaseEntities.push_back(EntityInfo());
+ const CXXRecordDecl *BaseRD = 0;
+ if (const RecordType *RT = Base.getType()->getAs<RecordType>())
+ BaseRD = dyn_cast_or_null<CXXRecordDecl>(RT->getDecl());
+ IdxCtx.getEntityInfo(BaseRD, BaseEntities.back(), SA);
+ CXIdxBaseClassInfo BaseInfo = { 0,
+ MakeCursorCXXBaseSpecifier(&Base, IdxCtx.CXTU),
+ IdxCtx.getIndexLoc(Base.getSourceRange().getBegin()) };
+ BaseInfos.push_back(BaseInfo);
+ }
+
+ for (unsigned i = 0, e = BaseInfos.size(); i != e; ++i) {
+ if (BaseEntities[i].USR)
+ BaseInfos[i].base = &BaseEntities[i];
+ }
+
+ for (unsigned i = 0, e = BaseInfos.size(); i != e; ++i)
+ CXBases.push_back(&BaseInfos[i]);
+}
+
const char *IndexingContext::StrAdapter::toCStr(StringRef Str) {
if (Str.empty())
return "";
@@ -155,31 +181,33 @@
DeclInfo &DInfo) {
if (!CB.indexDeclaration || !D)
return false;
+ if (D->isImplicit() && shouldIgnoreIfImplicit(D))
+ return false;
StrAdapter SA(*this);
- getEntityInfo(D, DInfo.CXEntInfo, SA);
- if (!DInfo.CXEntInfo.USR || Loc.isInvalid())
+ getEntityInfo(D, DInfo.EntInfo, SA);
+ if (!DInfo.EntInfo.USR || Loc.isInvalid())
return false;
markEntityOccurrenceInFile(D, Loc);
- DInfo.entityInfo = &DInfo.CXEntInfo;
+ DInfo.entityInfo = &DInfo.EntInfo;
DInfo.cursor = Cursor;
DInfo.loc = getIndexLoc(Loc);
- DInfo.container = getIndexContainer(D);
DInfo.isImplicit = D->isImplicit();
AttrListInfo AttrList(D, *this, SA);
DInfo.attributes = AttrList.getAttrs();
DInfo.numAttributes = AttrList.getNumAttrs();
- CXIdxClientContainer clientCont = 0;
- CXIdxDeclOut DeclOut = { DInfo.isContainer ? &clientCont : 0 };
- CB.indexDeclaration(ClientData, &DInfo, &DeclOut);
-
- if (DInfo.isContainer)
- addContainerInMap(cast<DeclContext>(D), clientCont);
+ getContainerInfo(D->getDeclContext(), DInfo.Container);
+ DInfo.container = &DInfo.Container;
+ if (DInfo.isContainer) {
+ getContainerInfo(getEntityContainer(D), DInfo.DeclAsContainer);
+ DInfo.declAsContainer = &DInfo.DeclAsContainer;
+ }
+ CB.indexDeclaration(ClientData, &DInfo);
return true;
}
@@ -215,12 +243,15 @@
}
bool IndexingContext::handleTagDecl(const TagDecl *D) {
+ if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(D))
+ return handleCXXRecordDecl(CXXRD, D);
+
DeclInfo DInfo(!D->isFirstDeclaration(), D->isThisDeclarationADefinition(),
D->isThisDeclarationADefinition());
return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
}
-bool IndexingContext::handleTypedef(const TypedefDecl *D) {
+bool IndexingContext::handleTypedefName(const TypedefNameDecl *D) {
DeclInfo DInfo(!D->isFirstDeclaration(), /*isDefinition=*/true,
/*isContainer=*/false);
return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
@@ -242,7 +273,7 @@
StrAdapter SA(*this);
CXIdxBaseClassInfo BaseClass;
- CXIdxEntityInfo BaseEntity;
+ EntityInfo BaseEntity;
BaseClass.cursor = clang_getNullCursor();
if (ObjCInterfaceDecl *SuperD = D->getSuperClass()) {
getEntityInfo(SuperD, BaseEntity, SA);
@@ -293,7 +324,7 @@
bool IndexingContext::handleObjCCategory(const ObjCCategoryDecl *D) {
ObjCCategoryDeclInfo CatDInfo(/*isImplementation=*/false);
- CXIdxEntityInfo ClassEntity;
+ EntityInfo ClassEntity;
StrAdapter SA(*this);
const ObjCInterfaceDecl *IFaceD = D->getClassInterface();
SourceLocation ClassLoc = D->getLocation();
@@ -317,7 +348,7 @@
bool IndexingContext::handleObjCCategoryImpl(const ObjCCategoryImplDecl *D) {
const ObjCCategoryDecl *CatD = D->getCategoryDecl();
ObjCCategoryDeclInfo CatDInfo(/*isImplementation=*/true);
- CXIdxEntityInfo ClassEntity;
+ EntityInfo ClassEntity;
StrAdapter SA(*this);
const ObjCInterfaceDecl *IFaceD = CatD->getClassInterface();
SourceLocation ClassLoc = D->getLocation();
@@ -362,6 +393,23 @@
return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
}
+bool IndexingContext::handleClassTemplate(const ClassTemplateDecl *D) {
+ return handleCXXRecordDecl(D->getTemplatedDecl(), D);
+}
+
+bool IndexingContext::handleFunctionTemplate(const FunctionTemplateDecl *D) {
+ DeclInfo DInfo(/*isRedeclaration=*/!D->isCanonicalDecl(),
+ /*isDefinition=*/D->isThisDeclarationADefinition(),
+ /*isContainer=*/D->isThisDeclarationADefinition());
+ return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
+}
+
+bool IndexingContext::handleTypeAliasTemplate(const TypeAliasTemplateDecl *D) {
+ DeclInfo DInfo(/*isRedeclaration=*/!D->isCanonicalDecl(),
+ /*isDefinition=*/true, /*isContainer=*/false);
+ return handleDecl(D, D->getLocation(), getCursor(D), DInfo);
+}
+
bool IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
const NamedDecl *Parent,
const DeclContext *DC,
@@ -382,35 +430,41 @@
const DeclContext *DC,
const Expr *E,
CXIdxEntityRefKind Kind) {
- if (!D)
+ if (!CB.indexEntityReference)
return false;
- if (D->getParentFunctionOrMethod())
+
+ if (!D)
return false;
if (Loc.isInvalid())
return false;
- if (!CB.indexEntityReference)
+ if (D->getParentFunctionOrMethod())
return false;
if (isNotFromSourceFile(D->getLocation()))
return false;
+ if (D->isImplicit() && shouldIgnoreIfImplicit(D))
+ return false;
+
+ if (suppressRefs()) {
+ if (markEntityOccurrenceInFile(D, Loc))
+ return false; // already occurred.
+ }
StrAdapter SA(*this);
- CXIdxEntityInfo RefEntity, ParentEntity;
+ EntityInfo RefEntity, ParentEntity;
getEntityInfo(D, RefEntity, SA);
if (!RefEntity.USR)
return false;
getEntityInfo(Parent, ParentEntity, SA);
- if (suppressRefs()) {
- if (markEntityOccurrenceInFile(D, Loc))
- return false; // already occurred.
- }
+ ContainerInfo Container;
+ getContainerInfo(DC, Container);
CXIdxEntityRefInfo Info = { Cursor,
getIndexLoc(Loc),
&RefEntity,
Parent ? &ParentEntity : 0,
- getIndexContainerForDC(DC),
+ &Container,
Kind };
CB.indexEntityReference(ClientData, &Info);
return true;
@@ -427,6 +481,9 @@
void IndexingContext::addContainerInMap(const DeclContext *DC,
CXIdxClientContainer container) {
+ if (!DC)
+ return;
+
assert(getScopedContext(DC) == DC);
ContainerMapTy::iterator I = ContainerMap.find(DC);
if (I == ContainerMap.end()) {
@@ -442,6 +499,34 @@
ContainerMap.erase(I);
}
+CXIdxClientEntity IndexingContext::getClientEntity(const Decl *D) const {
+ if (!D)
+ return 0;
+ EntityMapTy::const_iterator I = EntityMap.find(D);
+ if (I == EntityMap.end())
+ return 0;
+ return I->second;
+}
+
+void IndexingContext::setClientEntity(const Decl *D, CXIdxClientEntity client) {
+ if (!D)
+ return;
+ EntityMap[D] = client;
+}
+
+bool IndexingContext::handleCXXRecordDecl(const CXXRecordDecl *RD,
+ const NamedDecl *OrigD) {
+ StrAdapter SA(*this);
+ CXXClassDeclInfo DInfo(/*isRedeclaration=*/!OrigD->isCanonicalDecl(),
+ /*isDefinition=*/RD->isThisDeclarationADefinition());
+ CXXBasesListInfo BaseList(RD, *this, SA);
+ DInfo.CXXClassInfo.declInfo = &DInfo;
+ DInfo.CXXClassInfo.bases = BaseList.getBases();
+ DInfo.CXXClassInfo.numBases = BaseList.getNumBases();
+
+ return handleDecl(OrigD, OrigD->getLocation(), getCursor(OrigD), DInfo);
+}
+
bool IndexingContext::markEntityOccurrenceInFile(const NamedDecl *D,
SourceLocation Loc) {
SourceManager &SM = Ctx->getSourceManager();
@@ -476,12 +561,34 @@
} else if (const ObjCCategoryImplDecl *
CatImplD = dyn_cast<ObjCCategoryImplDecl>(D)) {
return getEntityDecl(CatImplD->getCategoryDecl());
+ } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ if (FunctionTemplateDecl *TemplD = FD->getDescribedFunctionTemplate())
+ return getEntityDecl(TemplD);
+ } else if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
+ if (ClassTemplateDecl *TemplD = RD->getDescribedClassTemplate())
+ return getEntityDecl(TemplD);
}
return D;
}
const DeclContext *
+IndexingContext::getEntityContainer(const Decl *D) const {
+ const DeclContext *DC = dyn_cast<DeclContext>(D);
+ if (DC)
+ return DC;
+
+ if (const ClassTemplateDecl *ClassTempl = dyn_cast<ClassTemplateDecl>(D)) {
+ DC = ClassTempl->getTemplatedDecl();
+ } if (const FunctionTemplateDecl *
+ FuncTempl = dyn_cast<FunctionTemplateDecl>(D)) {
+ DC = FuncTempl->getTemplatedDecl();
+ }
+
+ return DC;
+}
+
+const DeclContext *
IndexingContext::getScopedContext(const DeclContext *DC) const {
// Local contexts are ignored for indexing.
const DeclContext *FuncCtx = cast<Decl>(DC)->getParentFunctionOrMethod();
@@ -502,13 +609,15 @@
}
CXIdxClientContainer
-IndexingContext::getIndexContainerForDC(const DeclContext *DC) const {
+IndexingContext::getClientContainerForDC(const DeclContext *DC) const {
+ if (!DC)
+ return 0;
+
DC = getScopedContext(DC);
ContainerMapTy::const_iterator I = ContainerMap.find(DC);
if (I == ContainerMap.end())
return 0;
-// assert(I != ContainerMap.end() &&
-// "Failed to include a scoped context in the container map");
+
return I->second;
}
@@ -564,12 +673,18 @@
}
void IndexingContext::getEntityInfo(const NamedDecl *D,
- CXIdxEntityInfo &EntityInfo,
- StrAdapter &SA) {
+ EntityInfo &EntityInfo,
+ StrAdapter &SA) {
+ EntityInfo.name = EntityInfo.USR = 0;
if (!D)
return;
+
D = getEntityDecl(D);
+ EntityInfo.cursor = getCursor(D);
+ EntityInfo.Dcl = D;
+ EntityInfo.IndexCtx = this;
EntityInfo.kind = CXIdxEntity_Unexposed;
+ EntityInfo.templateKind = CXIdxEntity_NonTemplate;
if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
switch (TD->getTagKind()) {
@@ -583,14 +698,29 @@
EntityInfo.kind = CXIdxEntity_Enum; break;
}
+ if (const CXXRecordDecl *CXXRec = dyn_cast<CXXRecordDecl>(D)) {
+ if (TD->getTagKind() == TTK_Struct && !CXXRec->isPOD())
+ EntityInfo.kind = CXIdxEntity_CXXClass;
+ }
+
+ if (isa<ClassTemplatePartialSpecializationDecl>(D)) {
+ EntityInfo.templateKind = CXIdxEntity_TemplatePartialSpecialization;
+ } else if (isa<ClassTemplateSpecializationDecl>(D)) {
+ EntityInfo.templateKind = CXIdxEntity_TemplateSpecialization;
+ }
+
} else {
switch (D->getKind()) {
case Decl::Typedef:
EntityInfo.kind = CXIdxEntity_Typedef; break;
case Decl::Function:
- EntityInfo.kind = CXIdxEntity_Function; break;
+ EntityInfo.kind = CXIdxEntity_Function;
+ break;
case Decl::Var:
- EntityInfo.kind = CXIdxEntity_Variable; break;
+ EntityInfo.kind = CXIdxEntity_Variable;
+ if (isa<CXXRecordDecl>(D->getDeclContext()))
+ EntityInfo.kind = CXIdxEntity_CXXStaticVariable;
+ break;
case Decl::Field:
EntityInfo.kind = CXIdxEntity_Field; break;
case Decl::EnumConstant:
@@ -611,11 +741,67 @@
EntityInfo.kind = CXIdxEntity_ObjCProperty; break;
case Decl::ObjCIvar:
EntityInfo.kind = CXIdxEntity_ObjCIvar; break;
+ case Decl::Namespace:
+ EntityInfo.kind = CXIdxEntity_CXXNamespace; break;
+ case Decl::NamespaceAlias:
+ EntityInfo.kind = CXIdxEntity_CXXNamespaceAlias; break;
+ case Decl::CXXConstructor:
+ EntityInfo.kind = CXIdxEntity_CXXConstructor; break;
+ case Decl::CXXDestructor:
+ EntityInfo.kind = CXIdxEntity_CXXDestructor; break;
+ case Decl::CXXConversion:
+ EntityInfo.kind = CXIdxEntity_CXXConversionFunction; break;
+ case Decl::CXXMethod: {
+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(D);
+ if (MD->isStatic())
+ EntityInfo.kind = CXIdxEntity_CXXStaticMethod;
+ else
+ EntityInfo.kind = CXIdxEntity_CXXInstanceMethod;
+ break;
+ }
+ case Decl::ClassTemplate:
+ EntityInfo.kind = CXIdxEntity_CXXClass;
+ EntityInfo.templateKind = CXIdxEntity_Template;
+ break;
+ case Decl::FunctionTemplate:
+ EntityInfo.kind = CXIdxEntity_Function;
+ EntityInfo.templateKind = CXIdxEntity_Template;
+ if (const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(
+ cast<FunctionTemplateDecl>(D)->getTemplatedDecl())) {
+ if (isa<CXXConstructorDecl>(MD))
+ EntityInfo.kind = CXIdxEntity_CXXConstructor;
+ else if (isa<CXXDestructorDecl>(MD))
+ EntityInfo.kind = CXIdxEntity_CXXDestructor;
+ else if (isa<CXXConversionDecl>(MD))
+ EntityInfo.kind = CXIdxEntity_CXXConversionFunction;
+ else {
+ if (MD->isStatic())
+ EntityInfo.kind = CXIdxEntity_CXXStaticMethod;
+ else
+ EntityInfo.kind = CXIdxEntity_CXXInstanceMethod;
+ }
+ }
+ break;
+ case Decl::TypeAliasTemplate:
+ EntityInfo.kind = CXIdxEntity_CXXTypeAlias;
+ EntityInfo.templateKind = CXIdxEntity_Template;
+ break;
+ case Decl::TypeAlias:
+ EntityInfo.kind = CXIdxEntity_CXXTypeAlias; break;
default:
break;
}
}
+ if (EntityInfo.kind == CXIdxEntity_Unexposed)
+ return;
+
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ if (FD->getTemplatedKind() ==
+ FunctionDecl::TK_FunctionTemplateSpecialization)
+ EntityInfo.templateKind = CXIdxEntity_TemplateSpecialization;
+ }
+
if (IdentifierInfo *II = D->getIdentifier()) {
EntityInfo.name = SA.toCStr(II->getName());
@@ -642,6 +828,13 @@
}
}
+void IndexingContext::getContainerInfo(const DeclContext *DC,
+ ContainerInfo &ContInfo) {
+ ContInfo.cursor = getCursor(cast<Decl>(DC));
+ ContInfo.DC = DC;
+ ContInfo.IndexCtx = this;
+}
+
CXCursor IndexingContext::getRefCursor(const NamedDecl *D, SourceLocation Loc) {
if (const TypeDecl *TD = dyn_cast<TypeDecl>(D))
return MakeCursorTypeRef(TD, Loc, CXTU);
@@ -660,3 +853,11 @@
return clang_getNullCursor();
}
+
+bool IndexingContext::shouldIgnoreIfImplicit(const NamedDecl *D) {
+ if (isa<ObjCIvarDecl>(D))
+ return false;
+ if (isa<ObjCMethodDecl>(D))
+ return false;
+ return true;
+}
Modified: cfe/trunk/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.h?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.h (original)
+++ cfe/trunk/tools/libclang/IndexingContext.h Tue Nov 22 01:24:51 2011
@@ -18,23 +18,41 @@
class FileEntry;
class ObjCPropertyDecl;
class ObjCClassDecl;
+ class ClassTemplateDecl;
+ class FunctionTemplateDecl;
+ class TypeAliasTemplateDecl;
namespace cxindex {
class IndexingContext;
+struct EntityInfo : public CXIdxEntityInfo {
+ const NamedDecl *Dcl;
+ IndexingContext *IndexCtx;
+};
+
+struct ContainerInfo : public CXIdxContainerInfo {
+ const DeclContext *DC;
+ IndexingContext *IndexCtx;
+};
+
struct DeclInfo : public CXIdxDeclInfo {
- CXIdxEntityInfo CXEntInfo;
enum DInfoKind {
Info_Decl,
Info_ObjCContainer,
Info_ObjCInterface,
Info_ObjCProtocol,
- Info_ObjCCategory
+ Info_ObjCCategory,
+
+ Info_CXXClass
};
DInfoKind Kind;
+ EntityInfo EntInfo;
+ ContainerInfo Container;
+ ContainerInfo DeclAsContainer;
+
DeclInfo(bool isRedeclaration, bool isDefinition, bool isContainer)
: Kind(Info_Decl) {
this->isRedeclaration = isRedeclaration;
@@ -42,6 +60,7 @@
this->isContainer = isContainer;
attributes = 0;
numAttributes = 0;
+ declAsContainer = container = 0;
}
DeclInfo(DInfoKind K,
bool isRedeclaration, bool isDefinition, bool isContainer)
@@ -51,6 +70,7 @@
this->isContainer = isContainer;
attributes = 0;
numAttributes = 0;
+ declAsContainer = container = 0;
}
static bool classof(const DeclInfo *) { return true; }
@@ -137,6 +157,18 @@
static bool classof(const ObjCCategoryDeclInfo *D) { return true; }
};
+struct CXXClassDeclInfo : public DeclInfo {
+ CXIdxCXXClassDeclInfo CXXClassInfo;
+
+ CXXClassDeclInfo(bool isRedeclaration, bool isDefinition)
+ : DeclInfo(Info_CXXClass, isRedeclaration, isDefinition, isDefinition) { }
+
+ static bool classof(const DeclInfo *D) {
+ return D->Kind == Info_CXXClass;
+ }
+ static bool classof(const CXXClassDeclInfo *D) { return true; }
+};
+
struct AttrInfo : public CXIdxAttrInfo {
const Attr *A;
@@ -151,7 +183,7 @@
};
struct IBOutletCollectionInfo : public AttrInfo {
- CXIdxEntityInfo CXClassInfo;
+ EntityInfo ClassInfo;
CXIdxIBOutletCollectionAttrInfo IBCollInfo;
IBOutletCollectionInfo(CXCursor C, CXIdxLoc Loc, const Attr *A) :
@@ -181,9 +213,13 @@
CXTranslationUnit CXTU;
typedef llvm::DenseMap<const FileEntry *, CXIdxClientFile> FileMapTy;
- typedef llvm::DenseMap<const DeclContext *, CXIdxClientContainer> ContainerMapTy;
+ typedef llvm::DenseMap<const DeclContext *, CXIdxClientContainer>
+ ContainerMapTy;
+ typedef llvm::DenseMap<const Decl *, CXIdxClientEntity> EntityMapTy;
+
FileMapTy FileMap;
ContainerMapTy ContainerMap;
+ EntityMapTy EntityMap;
llvm::DenseSet<RefFileOccurence> RefFileOccurences;
@@ -222,7 +258,7 @@
struct ObjCProtocolListInfo {
SmallVector<CXIdxObjCProtocolRefInfo, 4> ProtInfos;
- SmallVector<CXIdxEntityInfo, 4> ProtEntities;
+ SmallVector<EntityInfo, 4> ProtEntities;
SmallVector<CXIdxObjCProtocolRefInfo *, 4> Prots;
CXIdxObjCProtocolRefListInfo getListInfo() const {
@@ -249,7 +285,21 @@
AttrListInfo(const Decl *D,
IndexingContext &IdxCtx,
IndexingContext::StrAdapter &SA);
-};
+ };
+
+ struct CXXBasesListInfo {
+ SmallVector<CXIdxBaseClassInfo, 4> BaseInfos;
+ SmallVector<EntityInfo, 4> BaseEntities;
+ SmallVector<CXIdxBaseClassInfo *, 4> CXBases;
+
+ const CXIdxBaseClassInfo *const *getBases() const {
+ return CXBases.data();
+ }
+ unsigned getNumBases() const { return (unsigned)CXBases.size(); }
+
+ CXXBasesListInfo(const CXXRecordDecl *D,
+ IndexingContext &IdxCtx, IndexingContext::StrAdapter &SA);
+ };
public:
IndexingContext(CXClientData clientData, IndexerCallbacks &indexCallbacks,
@@ -301,7 +351,7 @@
bool handleTagDecl(const TagDecl *D);
- bool handleTypedef(const TypedefDecl *D);
+ bool handleTypedefName(const TypedefNameDecl *D);
bool handleObjCClass(const ObjCClassDecl *D);
bool handleObjCInterface(const ObjCInterfaceDecl *D);
@@ -323,6 +373,10 @@
bool handleObjCProperty(const ObjCPropertyDecl *D);
+ bool handleClassTemplate(const ClassTemplateDecl *D);
+ bool handleFunctionTemplate(const FunctionTemplateDecl *D);
+ bool handleTypeAliasTemplate(const TypeAliasTemplateDecl *D);
+
bool handleReference(const NamedDecl *D, SourceLocation Loc, CXCursor Cursor,
const NamedDecl *Parent,
const DeclContext *DC,
@@ -348,6 +402,12 @@
void translateLoc(SourceLocation Loc, CXIdxClientFile *indexFile, CXFile *file,
unsigned *line, unsigned *column, unsigned *offset);
+ CXIdxClientContainer getClientContainerForDC(const DeclContext *DC) const;
+ void addContainerInMap(const DeclContext *DC, CXIdxClientContainer container);
+
+ CXIdxClientEntity getClientEntity(const Decl *D) const;
+ void setClientEntity(const Decl *D, CXIdxClientEntity client);
+
private:
bool handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
@@ -357,32 +417,37 @@
SourceLocation Loc, CXCursor Cursor,
ObjCContainerDeclInfo &ContDInfo);
- void addContainerInMap(const DeclContext *DC, CXIdxClientContainer container);
+ bool handleCXXRecordDecl(const CXXRecordDecl *RD, const NamedDecl *OrigD);
bool markEntityOccurrenceInFile(const NamedDecl *D, SourceLocation Loc);
const NamedDecl *getEntityDecl(const NamedDecl *D) const;
- CXIdxClientContainer getIndexContainer(const NamedDecl *D) const {
- return getIndexContainerForDC(D->getDeclContext());
+ const DeclContext *getEntityContainer(const Decl *D) const;
+
+ CXIdxClientContainer getClientContainer(const NamedDecl *D) const {
+ return getClientContainerForDC(D->getDeclContext());
}
const DeclContext *getScopedContext(const DeclContext *DC) const;
- CXIdxClientContainer getIndexContainerForDC(const DeclContext *DC) const;
CXIdxClientFile getIndexFile(const FileEntry *File);
CXIdxLoc getIndexLoc(SourceLocation Loc) const;
void getEntityInfo(const NamedDecl *D,
- CXIdxEntityInfo &EntityInfo,
+ EntityInfo &EntityInfo,
StrAdapter &SA);
+ void getContainerInfo(const DeclContext *DC, ContainerInfo &ContInfo);
+
CXCursor getCursor(const Decl *D) {
return cxcursor::MakeCXCursor(const_cast<Decl*>(D), CXTU);
}
CXCursor getRefCursor(const NamedDecl *D, SourceLocation Loc);
+
+ static bool shouldIgnoreIfImplicit(const NamedDecl *D);
};
}} // end clang::cxindex
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=145058&r1=145057&r2=145058&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Tue Nov 22 01:24:51 2011
@@ -135,12 +135,19 @@
clang_getTypeDeclaration
clang_getTypeKindSpelling
clang_hashCursor
+clang_IndexAction_create
+clang_IndexAction_dispose
+clang_index_getClientContainer
+clang_index_getClientEntity
+clang_index_getCXXClassDeclInfo
clang_index_getIBOutletCollectionAttrInfo
clang_index_getObjCCategoryDeclInfo
clang_index_getObjCContainerDeclInfo
clang_index_getObjCInterfaceDeclInfo
clang_index_getObjCProtocolRefListInfo
clang_index_isEntityObjCContainerKind
+clang_index_setClientContainer
+clang_index_setClientEntity
clang_indexLoc_getCXSourceLocation
clang_indexLoc_getFileLocation
clang_indexSourceFile
More information about the cfe-commits
mailing list