aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-13 21:13:43 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-03-13 21:13:43 +0000
commitc1d22393628a145e54396c0ac66e9625d13a7658 (patch)
tree90980c81a5c5e14533e0f5e5b41fd48bcbb4d0b8 /tools
parentad4b8b43e66ebc2838fb314358017079665f058f (diff)
[Modules] Resolve top-headers of modules lazily.
This allows resolving top-header filenames of modules to FileEntries when we need them, not eagerly. Note that that this breaks ABI for libclang functions clang_Module_getTopLevelHeader / clang_Module_getNumTopLevelHeaders but this is fine because they are experimental and not widely used yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176975 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/c-index-test/c-index-test.c4
-rw-r--r--tools/libclang/CIndex.cpp20
2 files changed, 15 insertions, 9 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 46d61e995c..88b49edaaf 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1996,12 +1996,12 @@ static int inspect_cursor_at(int argc, const char **argv) {
unsigned i, numHeaders;
if (mod) {
name = clang_Module_getFullName(mod);
- numHeaders = clang_Module_getNumTopLevelHeaders(mod);
+ numHeaders = clang_Module_getNumTopLevelHeaders(TU, mod);
printf(" ModuleName=%s Headers(%d):",
clang_getCString(name), numHeaders);
clang_disposeString(name);
for (i = 0; i < numHeaders; ++i) {
- CXFile file = clang_Module_getTopLevelHeader(mod, i);
+ CXFile file = clang_Module_getTopLevelHeader(TU, mod, i);
CXString filename = clang_getFileName(file);
printf("\n%s", clang_getCString(filename));
clang_disposeString(filename);
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index a2449bdc3f..d63f4def29 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -5984,20 +5984,26 @@ CXString clang_Module_getFullName(CXModule CXMod) {
return cxstring::createDup(Mod->getFullModuleName());
}
-unsigned clang_Module_getNumTopLevelHeaders(CXModule CXMod) {
- if (!CXMod)
+unsigned clang_Module_getNumTopLevelHeaders(CXTranslationUnit TU,
+ CXModule CXMod) {
+ if (!TU || !CXMod)
return 0;
Module *Mod = static_cast<Module*>(CXMod);
- return Mod->TopHeaders.size();
+ FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager();
+ ArrayRef<const FileEntry *> TopHeaders = Mod->getTopHeaders(FileMgr);
+ return TopHeaders.size();
}
-CXFile clang_Module_getTopLevelHeader(CXModule CXMod, unsigned Index) {
- if (!CXMod)
+CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU,
+ CXModule CXMod, unsigned Index) {
+ if (!TU || !CXMod)
return 0;
Module *Mod = static_cast<Module*>(CXMod);
+ FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager();
- if (Index < Mod->TopHeaders.size())
- return const_cast<FileEntry *>(Mod->TopHeaders[Index]);
+ ArrayRef<const FileEntry *> TopHeaders = Mod->getTopHeaders(FileMgr);
+ if (Index < TopHeaders.size())
+ return const_cast<FileEntry *>(TopHeaders[Index]);
return 0;
}