forked from OSchip/llvm-project
[libclang] Indexing API: provide both the semantic and the lexical container.
They are generally the same except in C++ cases like out-of-line member functions. llvm-svn: 146069
This commit is contained in:
parent
b3c16bad20
commit
663c8ecda1
|
@ -4199,7 +4199,12 @@ typedef struct {
|
|||
const CXIdxEntityInfo *entityInfo;
|
||||
CXCursor cursor;
|
||||
CXIdxLoc loc;
|
||||
const CXIdxContainerInfo *container;
|
||||
const CXIdxContainerInfo *semanticContainer;
|
||||
/**
|
||||
* \brief Generally same as \see semanticContainer but can be different in
|
||||
* cases like out-of-line C++ member functions.
|
||||
*/
|
||||
const CXIdxContainerInfo *lexicalContainer;
|
||||
int isRedeclaration;
|
||||
int isDefinition;
|
||||
int isContainer;
|
||||
|
@ -4279,6 +4284,7 @@ typedef enum {
|
|||
* \brief Data for \see indexEntityReference callback.
|
||||
*/
|
||||
typedef struct {
|
||||
CXIdxEntityRefKind kind;
|
||||
/**
|
||||
* \brief Reference cursor.
|
||||
*/
|
||||
|
@ -4303,7 +4309,6 @@ typedef struct {
|
|||
* \brief Container context of the reference.
|
||||
*/
|
||||
const CXIdxContainerInfo *container;
|
||||
CXIdxEntityRefKind kind;
|
||||
} CXIdxEntityRefInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -1801,8 +1801,10 @@ static void index_indexDeclaration(CXClientData client_data,
|
|||
PrintCursor(info->cursor);
|
||||
printf(" | loc: ");
|
||||
printCXIndexLoc(info->loc);
|
||||
printf(" | container: ");
|
||||
printCXIndexContainer(info->container);
|
||||
printf(" | semantic-container: ");
|
||||
printCXIndexContainer(info->semanticContainer);
|
||||
printf(" | lexical-container: ");
|
||||
printCXIndexContainer(info->lexicalContainer);
|
||||
printf(" | isRedecl: %d", info->isRedeclaration);
|
||||
printf(" | isDef: %d", info->isDefinition);
|
||||
printf(" | isContainer: %d", info->isContainer);
|
||||
|
|
|
@ -239,8 +239,10 @@ bool IndexingContext::handleDecl(const NamedDecl *D,
|
|||
DInfo.attributes = AttrList.getAttrs();
|
||||
DInfo.numAttributes = AttrList.getNumAttrs();
|
||||
|
||||
getContainerInfo(D->getDeclContext(), DInfo.Container);
|
||||
DInfo.container = &DInfo.Container;
|
||||
getContainerInfo(D->getDeclContext(), DInfo.SemanticContainer);
|
||||
getContainerInfo(D->getLexicalDeclContext(), DInfo.LexicalContainer);
|
||||
DInfo.semanticContainer = &DInfo.SemanticContainer;
|
||||
DInfo.lexicalContainer = &DInfo.LexicalContainer;
|
||||
if (DInfo.isContainer) {
|
||||
getContainerInfo(getEntityContainer(D), DInfo.DeclAsContainer);
|
||||
DInfo.declAsContainer = &DInfo.DeclAsContainer;
|
||||
|
@ -506,12 +508,12 @@ bool IndexingContext::handleReference(const NamedDecl *D, SourceLocation Loc,
|
|||
ContainerInfo Container;
|
||||
getContainerInfo(DC, Container);
|
||||
|
||||
CXIdxEntityRefInfo Info = { Cursor,
|
||||
CXIdxEntityRefInfo Info = { Kind,
|
||||
Cursor,
|
||||
getIndexLoc(Loc),
|
||||
&RefEntity,
|
||||
Parent ? &ParentEntity : 0,
|
||||
&Container,
|
||||
Kind };
|
||||
&Container };
|
||||
CB.indexEntityReference(ClientData, &Info);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,8 @@ struct DeclInfo : public CXIdxDeclInfo {
|
|||
DInfoKind Kind;
|
||||
|
||||
EntityInfo EntInfo;
|
||||
ContainerInfo Container;
|
||||
ContainerInfo SemanticContainer;
|
||||
ContainerInfo LexicalContainer;
|
||||
ContainerInfo DeclAsContainer;
|
||||
|
||||
DeclInfo(bool isRedeclaration, bool isDefinition, bool isContainer)
|
||||
|
@ -64,7 +65,7 @@ struct DeclInfo : public CXIdxDeclInfo {
|
|||
this->isContainer = isContainer;
|
||||
attributes = 0;
|
||||
numAttributes = 0;
|
||||
declAsContainer = container = 0;
|
||||
declAsContainer = semanticContainer = lexicalContainer = 0;
|
||||
}
|
||||
DeclInfo(DInfoKind K,
|
||||
bool isRedeclaration, bool isDefinition, bool isContainer)
|
||||
|
@ -74,7 +75,7 @@ struct DeclInfo : public CXIdxDeclInfo {
|
|||
this->isContainer = isContainer;
|
||||
attributes = 0;
|
||||
numAttributes = 0;
|
||||
declAsContainer = container = 0;
|
||||
declAsContainer = semanticContainer = lexicalContainer = 0;
|
||||
}
|
||||
|
||||
static bool classof(const DeclInfo *) { return true; }
|
||||
|
|
Loading…
Reference in New Issue