diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Lex/HeaderSearch.cpp | 22 | ||||
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 12 |
2 files changed, 19 insertions, 15 deletions
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index cc9c8c16f7..4deba60b9d 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -219,7 +219,7 @@ const FileEntry *DirectoryLookup::LookupFile( 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 @@ const FileEntry *DirectoryLookup::LookupFile( // 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 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup( SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath, StringRef BuildingModule, - StringRef *SuggestedModule) const + ModuleMap::Module **SuggestedModule) const { FileManager &FileMgr = HS.getFileMgr(); @@ -370,7 +370,7 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup( 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 *DirectoryLookup::DoFrameworkLookup( 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 *HeaderSearch::LookupFile( 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 @@ bool HeaderSearch::hasModuleMap(StringRef FileName, 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) { diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 9446d51f9d..2444364f35 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -486,7 +486,7 @@ const FileEntry *Preprocessor::LookupFile( const DirectoryLookup *&CurDir, SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath, - StringRef *SuggestedModule) { + ModuleMap::Module **SuggestedModule) { // If the header lookup mechanism may be relative to the current file, pass in // info about where the current file is. const FileEntry *CurFileEnt = 0; @@ -1269,7 +1269,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, llvm::SmallString<1024> RelativePath; // We get the raw path only if we have 'Callbacks' to which we later pass // the path. - StringRef SuggestedModule; + ModuleMap::Module *SuggestedModule = 0; const FileEntry *File = LookupFile( Filename, isAngled, LookupFrom, CurDir, Callbacks ? &SearchPath : NULL, Callbacks ? &RelativePath : NULL, @@ -1277,9 +1277,13 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // If we are supposed to import a module rather than including the header, // do so now. - if (!SuggestedModule.empty()) { + if (SuggestedModule) { + // FIXME: Actually load the submodule that we were given. + while (SuggestedModule->Parent) + SuggestedModule = SuggestedModule->Parent; + TheModuleLoader.loadModule(IncludeTok.getLocation(), - Identifiers.get(SuggestedModule), + Identifiers.get(SuggestedModule->Name), FilenameTok.getLocation()); return; } |