[libclang] Simplify indexing of module imports by handling implicit
imports via ImportDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165160 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp
index 3a3c010..c964e96 100644
--- a/tools/libclang/IndexingContext.cpp
+++ b/tools/libclang/IndexingContext.cpp
@@ -253,21 +253,20 @@
   FileMap[File] = idxFile;
 }
 
-void IndexingContext::importedModule(SourceLocation Loc,
-                                     StringRef name, bool isIncludeDirective,
-                                     const Module *module) {
+void IndexingContext::importedModule(const ImportDecl *ImportD) {
   if (!CB.importedASTFile)
     return;
 
-  std::string ModuleName = module->getFullModuleName();
+  Module *Mod = ImportD->getImportedModule();
+  if (!Mod)
+    return;
+  std::string ModuleName = Mod->getFullModuleName();
 
-  ScratchAlloc SA(*this);
   CXIdxImportedASTFileInfo Info = {
-                                    (CXFile)module->getASTFile(),
-                                    getIndexLoc(Loc),
+                                    (CXFile)Mod->getASTFile(),
+                                    getIndexLoc(ImportD->getLocation()),
                                     /*isModule=*/true,
-                                    isIncludeDirective,
-                                    SA.toCStr(name),
+                                    ImportD->isImplicit(),
                                     ModuleName.c_str(),
                                   };
   CXIdxClientASTFile astFile = CB.importedASTFile(ClientData, &Info);
@@ -1110,6 +1109,8 @@
     return false;
   if (isa<ObjCMethodDecl>(D))
     return false;
+  if (isa<ImportDecl>(D))
+    return false;
   return true;
 }