summaryrefslogtreecommitdiffstats
path: root/clang/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-26 22:47:49 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-26 22:47:49 +0000
commit12fdb9e34b8cc4cc848d4ef8c601de5e5faf694d (patch)
treee680c84ee2e8ac9cd9eef9cb353147ef7e4d1cb9 /clang/tools
parent62498ab4d54c946d84d1f2861954a4f41e306637 (diff)
downloadbcm5719-llvm-12fdb9e34b8cc4cc848d4ef8c601de5e5faf694d.tar.gz
bcm5719-llvm-12fdb9e34b8cc4cc848d4ef8c601de5e5faf694d.zip
[libclang] Introduce clang_Module_getASTFile function that returns the module file where a module object came from.
rdar://13743084 llvm-svn: 180643
Diffstat (limited to 'clang/tools')
-rw-r--r--clang/tools/c-index-test/c-index-test.c11
-rw-r--r--clang/tools/libclang/CIndex.cpp7
-rw-r--r--clang/tools/libclang/libclang.exports1
3 files changed, 16 insertions, 3 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 3f39a78625d..e5752341679 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -2105,14 +2105,19 @@ static int inspect_cursor_at(int argc, const char **argv) {
{
CXModule mod = clang_Cursor_getModule(Cursor);
- CXString name;
+ CXFile astFile;
+ CXString name, astFilename;
unsigned i, numHeaders;
if (mod) {
+ astFile = clang_Module_getASTFile(mod);
+ astFilename = clang_getFileName(astFile);
name = clang_Module_getFullName(mod);
numHeaders = clang_Module_getNumTopLevelHeaders(TU, mod);
- printf(" ModuleName=%s Headers(%d):",
- clang_getCString(name), numHeaders);
+ printf(" ModuleName=%s (%s) Headers(%d):",
+ clang_getCString(name), clang_getCString(astFilename),
+ numHeaders);
clang_disposeString(name);
+ clang_disposeString(astFilename);
for (i = 0; i < numHeaders; ++i) {
CXFile file = clang_Module_getTopLevelHeader(TU, mod, i);
CXString filename = clang_getFileName(file);
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 0a8a0689983..a43c1ab7e45 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -6055,6 +6055,13 @@ CXModule clang_Cursor_getModule(CXCursor C) {
return 0;
}
+CXFile clang_Module_getASTFile(CXModule CXMod) {
+ if (!CXMod)
+ return 0;
+ Module *Mod = static_cast<Module*>(CXMod);
+ return const_cast<FileEntry *>(Mod->getASTFile());
+}
+
CXModule clang_Module_getParent(CXModule CXMod) {
if (!CXMod)
return 0;
diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports
index c7508bc5449..0c9912e5202 100644
--- a/clang/tools/libclang/libclang.exports
+++ b/clang/tools/libclang/libclang.exports
@@ -21,6 +21,7 @@ clang_Cursor_isDynamicCall
clang_Cursor_isNull
clang_Cursor_isVariadic
clang_Cursor_getModule
+clang_Module_getASTFile
clang_Module_getParent
clang_Module_getName
clang_Module_getFullName
OpenPOWER on IntegriCloud