summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/CIndex.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-10-05 00:22:37 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-10-05 00:22:37 +0000
commit2b9b5bb697d40fe6a348464a6da66e74c81fdbd4 (patch)
treee80f63e8879504ce78e3a6a1fc032c0bbc27080e /clang/tools/libclang/CIndex.cpp
parentc597c8c48b977d70996bc55e36e230f264120516 (diff)
downloadbcm5719-llvm-2b9b5bb697d40fe6a348464a6da66e74c81fdbd4.tar.gz
bcm5719-llvm-2b9b5bb697d40fe6a348464a6da66e74c81fdbd4.zip
[libclang] Introduce new C functions that provide information about modules:
clang_Cursor_getModule clang_Module_getParent clang_Module_getName clang_Module_getFullName clang_Module_getNumTopLevelHeaders clang_Module_getTopLevelHeader llvm-svn: 165280
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
-rw-r--r--clang/tools/libclang/CIndex.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index abe3eea4afa..3543a39f7a3 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -5834,6 +5834,54 @@ CXComment clang_Cursor_getParsedComment(CXCursor C) {
return cxcomment::createCXComment(FC, getCursorTU(C));
}
+CXModule clang_Cursor_getModule(CXCursor C) {
+ if (C.kind == CXCursor_ModuleImportDecl) {
+ if (ImportDecl *ImportD = dyn_cast_or_null<ImportDecl>(getCursorDecl(C)))
+ return ImportD->getImportedModule();
+ }
+
+ return 0;
+}
+
+CXModule clang_Module_getParent(CXModule CXMod) {
+ if (!CXMod)
+ return 0;
+ Module *Mod = static_cast<Module*>(CXMod);
+ return Mod->Parent;
+}
+
+CXString clang_Module_getName(CXModule CXMod) {
+ if (!CXMod)
+ return createCXString("");
+ Module *Mod = static_cast<Module*>(CXMod);
+ return createCXString(Mod->Name);
+}
+
+CXString clang_Module_getFullName(CXModule CXMod) {
+ if (!CXMod)
+ return createCXString("");
+ Module *Mod = static_cast<Module*>(CXMod);
+ return createCXString(Mod->getFullModuleName());
+}
+
+unsigned clang_Module_getNumTopLevelHeaders(CXModule CXMod) {
+ if (!CXMod)
+ return 0;
+ Module *Mod = static_cast<Module*>(CXMod);
+ return Mod->TopHeaders.size();
+}
+
+CXFile clang_Module_getTopLevelHeader(CXModule CXMod, unsigned Index) {
+ if (!CXMod)
+ return 0;
+ Module *Mod = static_cast<Module*>(CXMod);
+
+ if (Index < Mod->TopHeaders.size())
+ return const_cast<FileEntry *>(Mod->TopHeaders[Index]);
+
+ return 0;
+}
+
} // end: extern "C"
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud