forked from OSchip/llvm-project
CIndex:
- Remove unused (and unimplemented) clang_getDeclarationName(). - Remove unused (and unimplemented) clang_getEntity(). - Add clang_getEntityFromDecl(): maps from a CXDecl to a CXEntity) - Add clang_getDeclaration(): maps from a (CXEntity, CXTranslationUnit) to a CXDecl). llvm-svn: 93209
This commit is contained in:
parent
6a19ed0b86
commit
e5f86be138
|
@ -142,7 +142,10 @@ typedef struct {
|
||||||
} CXCursor;
|
} CXCursor;
|
||||||
|
|
||||||
/* A unique token for looking up "visible" CXDecls from a CXTranslationUnit. */
|
/* A unique token for looking up "visible" CXDecls from a CXTranslationUnit. */
|
||||||
typedef void *CXEntity;
|
typedef struct {
|
||||||
|
CXIndex index;
|
||||||
|
void *data;
|
||||||
|
} CXEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For functions returning a string that might or might not need
|
* For functions returning a string that might or might not need
|
||||||
|
@ -321,14 +324,17 @@ CINDEX_LINKAGE time_t clang_getFileTime(CXFile SFile);
|
||||||
/*
|
/*
|
||||||
* CXEntity Operations.
|
* CXEntity Operations.
|
||||||
*/
|
*/
|
||||||
CINDEX_LINKAGE const char *clang_getDeclarationName(CXEntity);
|
|
||||||
|
/* clang_getDeclaration() maps from a CXEntity to the matching CXDecl (if any)
|
||||||
|
* in a specified translation unit. */
|
||||||
|
CINDEX_LINKAGE CXDecl clang_getDeclaration(CXEntity, CXTranslationUnit);
|
||||||
|
|
||||||
CINDEX_LINKAGE const char *clang_getUSR(CXEntity);
|
CINDEX_LINKAGE const char *clang_getUSR(CXEntity);
|
||||||
CINDEX_LINKAGE CXEntity clang_getEntity(const char *USR);
|
|
||||||
/*
|
/*
|
||||||
* CXDecl Operations.
|
* CXDecl Operations.
|
||||||
*/
|
*/
|
||||||
CINDEX_LINKAGE CXCursor clang_getCursorFromDecl(CXDecl);
|
CINDEX_LINKAGE CXCursor clang_getCursorFromDecl(CXDecl);
|
||||||
CINDEX_LINKAGE CXEntity clang_getEntityFromDecl(CXDecl);
|
CINDEX_LINKAGE CXEntity clang_getEntityFromDecl(CXIndex, CXDecl);
|
||||||
CINDEX_LINKAGE CXString clang_getDeclSpelling(CXDecl);
|
CINDEX_LINKAGE CXString clang_getDeclSpelling(CXDecl);
|
||||||
CINDEX_LINKAGE unsigned clang_getDeclLine(CXDecl);
|
CINDEX_LINKAGE unsigned clang_getDeclLine(CXDecl);
|
||||||
CINDEX_LINKAGE unsigned clang_getDeclColumn(CXDecl);
|
CINDEX_LINKAGE unsigned clang_getDeclColumn(CXDecl);
|
||||||
|
|
|
@ -628,10 +628,6 @@ void clang_loadDeclaration(CXDecl Dcl,
|
||||||
// CXDecl Operations.
|
// CXDecl Operations.
|
||||||
//
|
//
|
||||||
|
|
||||||
CXEntity clang_getEntityFromDecl(CXDecl) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CXString clang_getDeclSpelling(CXDecl AnonDecl) {
|
CXString clang_getDeclSpelling(CXDecl AnonDecl) {
|
||||||
assert(AnonDecl && "Passed null CXDecl");
|
assert(AnonDecl && "Passed null CXDecl");
|
||||||
NamedDecl *ND = static_cast<NamedDecl *>(AnonDecl);
|
NamedDecl *ND = static_cast<NamedDecl *>(AnonDecl);
|
||||||
|
|
|
@ -28,9 +28,8 @@ _clang_getDeclExtent
|
||||||
_clang_getDeclSource
|
_clang_getDeclSource
|
||||||
_clang_getDeclSourceFile
|
_clang_getDeclSourceFile
|
||||||
_clang_getDeclSpelling
|
_clang_getDeclSpelling
|
||||||
_clang_getDeclarationName
|
_clang_getDeclaration
|
||||||
_clang_getDefinitionSpellingAndExtent
|
_clang_getDefinitionSpellingAndExtent
|
||||||
_clang_getEntity
|
|
||||||
_clang_getEntityFromDecl
|
_clang_getEntityFromDecl
|
||||||
_clang_getFileName
|
_clang_getFileName
|
||||||
_clang_getFileTime
|
_clang_getFileTime
|
||||||
|
|
|
@ -30,17 +30,52 @@ extern "C" {
|
||||||
//
|
//
|
||||||
// module.m: static void Foo() { }
|
// module.m: static void Foo() { }
|
||||||
//
|
//
|
||||||
|
|
||||||
const char *clang_getDeclarationName(CXEntity) {
|
static inline Entity GetEntity(const CXEntity &E) {
|
||||||
return "";
|
return Entity::getFromOpaquePtr(E.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline ASTUnit *GetTranslationUnit(CXTranslationUnit TU) {
|
||||||
|
return (ASTUnit*) TU;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline ASTContext &GetASTContext(CXTranslationUnit TU) {
|
||||||
|
return GetTranslationUnit(TU)->getASTContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline CXEntity NullCXEntity() {
|
||||||
|
CXEntity CE;
|
||||||
|
CE.index = NULL;
|
||||||
|
CE.data = NULL;
|
||||||
|
return CE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline CXEntity MakeEntity(CXIndex CIdx, const Entity &E) {
|
||||||
|
CXEntity CE;
|
||||||
|
CE.index = CIdx;
|
||||||
|
CE.data = E.getAsOpaquePtr();
|
||||||
|
return CE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline Program &GetProgram(CXIndex CIdx) {
|
||||||
|
return ((CIndexer*) CIdx)->getProgram();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// clang_getDeclaration() maps from a CXEntity to the matching CXDecl (if any)
|
||||||
|
/// in a specified translation unit.
|
||||||
|
CXDecl clang_getDeclaration(CXEntity CE, CXTranslationUnit TU) {
|
||||||
|
return (CXDecl) GetEntity(CE).getDecl(GetASTContext(TU));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CXEntity clang_getEntityFromDecl(CXIndex CIdx, CXDecl CE) {
|
||||||
|
if (Decl *D = (Decl *) CE)
|
||||||
|
return MakeEntity(CIdx, Entity::get(D, GetProgram(CIdx)));
|
||||||
|
return NullCXEntity();
|
||||||
|
}
|
||||||
|
|
||||||
const char *clang_getUSR(CXEntity) {
|
const char *clang_getUSR(CXEntity) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
CXEntity clang_getEntity(const char *URI) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end extern "C"
|
} // end extern "C"
|
||||||
|
|
Loading…
Reference in New Issue