[libclang] Implement the importedASTFile indexing callback to provide
info about imported modules.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165020 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 210dc36..3a3c010 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -253,6 +253,27 @@
   FileMap[File] = idxFile;
 }
 
+void IndexingContext::importedModule(SourceLocation Loc,
+                                     StringRef name, bool isIncludeDirective,
+                                     const Module *module) {
+  if (!CB.importedASTFile)
+    return;
+
+  std::string ModuleName = module->getFullModuleName();
+
+  ScratchAlloc SA(*this);
+  CXIdxImportedASTFileInfo Info = {
+                                    (CXFile)module->getASTFile(),
+                                    getIndexLoc(Loc),
+                                    /*isModule=*/true,
+                                    isIncludeDirective,
+                                    SA.toCStr(name),
+                                    ModuleName.c_str(),
+                                  };
+  CXIdxClientASTFile astFile = CB.importedASTFile(ClientData, &Info);
+  (void)astFile;
+}
+
 void IndexingContext::startedTranslationUnit() {
   CXIdxClientContainer idxCont = 0;
   if (CB.startedTranslationUnit)