summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/CIndex.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-05-14 23:14:37 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-05-14 23:14:37 +0000
commitf6d49c36b2d23e468654cc9d307c865e5f9621c5 (patch)
tree50481c92328c21ade2d963a83a47d1868d09c993 /clang/tools/libclang/CIndex.cpp
parentbecce11112f65f0de12ece4fa6fe6435f72b7d3e (diff)
downloadbcm5719-llvm-f6d49c36b2d23e468654cc9d307c865e5f9621c5.tar.gz
bcm5719-llvm-f6d49c36b2d23e468654cc9d307c865e5f9621c5.zip
[liblang] Introduce clang_getModuleForFile, which given a CXFile header file, returns the module that contains it, if one exists.
llvm-svn: 208822
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
-rw-r--r--clang/tools/libclang/CIndex.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 754026eae17..f38d4c2bc87 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -6329,6 +6329,26 @@ CXModule clang_Cursor_getModule(CXCursor C) {
return 0;
}
+CXModule clang_getModuleForFile(CXTranslationUnit TU, CXFile File) {
+ if (isNotUsableTU(TU)) {
+ LOG_BAD_TU(TU);
+ return nullptr;
+ }
+ if (!File)
+ return nullptr;
+ FileEntry *FE = static_cast<FileEntry *>(File);
+
+ ASTUnit &Unit = *cxtu::getASTUnit(TU);
+ HeaderSearch &HS = Unit.getPreprocessor().getHeaderSearchInfo();
+ ModuleMap::KnownHeader Header = HS.findModuleForHeader(FE);
+
+ if (Module *Mod = Header.getModule()) {
+ if (Header.getRole() != ModuleMap::ExcludedHeader)
+ return Mod;
+ }
+ return nullptr;
+}
+
CXFile clang_Module_getASTFile(CXModule CXMod) {
if (!CXMod)
return 0;
OpenPOWER on IntegriCloud