When making a suggestion regarding which module to load rather than
preprocess/parse a header, report back with an actual module (which
may be a submodule) rather than just the name of the module.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144925 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp
index cc9c8c1..4deba60 100644
--- a/lib/Lex/HeaderSearch.cpp
+++ b/lib/Lex/HeaderSearch.cpp
@@ -219,7 +219,7 @@
     SmallVectorImpl<char> *SearchPath,
     SmallVectorImpl<char> *RelativePath,
     StringRef BuildingModule,
-    StringRef *SuggestedModule) const {
+    ModuleMap::Module **SuggestedModule) const {
   llvm::SmallString<1024> TmpDir;
   if (isNormalDir()) {
     // Concatenate the requested file onto the directory.
@@ -245,8 +245,8 @@
       
       // If there is a module that corresponds to this header, 
       // suggest it.
-      StringRef Module = HS.findModuleForHeader(File);
-      if (!Module.empty() && Module != BuildingModule)
+      ModuleMap::Module *Module = HS.findModuleForHeader(File);
+      if (Module && Module->getTopLevelModuleName() != BuildingModule)
         *SuggestedModule = Module;
       
       return File;
@@ -285,7 +285,7 @@
     SmallVectorImpl<char> *SearchPath,
     SmallVectorImpl<char> *RelativePath,
     StringRef BuildingModule,
-    StringRef *SuggestedModule) const 
+    ModuleMap::Module **SuggestedModule) const 
 {
   FileManager &FileMgr = HS.getFileMgr();
 
@@ -370,7 +370,7 @@
   if (const FileEntry *FE = FileMgr.getFile(FrameworkName.str(),
                                             /*openFile=*/!AutomaticImport)) {
     if (AutomaticImport)
-      *SuggestedModule = Module->Name;
+      *SuggestedModule = Module;
     return FE;
   }
 
@@ -385,7 +385,7 @@
   const FileEntry *FE = FileMgr.getFile(FrameworkName.str(), 
                                         /*openFile=*/!AutomaticImport);
   if (FE && AutomaticImport)
-    *SuggestedModule = Module->Name;
+    *SuggestedModule = Module;
   return FE;
 }
 
@@ -408,10 +408,10 @@
     const FileEntry *CurFileEnt,
     SmallVectorImpl<char> *SearchPath,
     SmallVectorImpl<char> *RelativePath,
-    StringRef *SuggestedModule) 
+    ModuleMap::Module **SuggestedModule) 
 {
   if (SuggestedModule)
-    *SuggestedModule = StringRef();
+    *SuggestedModule = 0;
     
   // If 'Filename' is absolute, check to see if it exists and no searching.
   if (llvm::sys::path::is_absolute(Filename)) {
@@ -806,11 +806,11 @@
   return false;
 }
 
-StringRef HeaderSearch::findModuleForHeader(const FileEntry *File) {
+ModuleMap::Module *HeaderSearch::findModuleForHeader(const FileEntry *File) {
   if (ModuleMap::Module *Module = ModMap.findModuleForHeader(File))
-    return Module->getTopLevelModuleName();
+    return Module;
   
-  return StringRef();
+  return 0;
 }
 
 bool HeaderSearch::loadModuleMapFile(const FileEntry *File) {