diff options
| author | Douglas Gregor <dgregor@apple.com> | 2013-02-08 00:10:48 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2013-02-08 00:10:48 +0000 |
| commit | f5f945280836dca2617c5d3848bcdeb9dbcab7de (patch) | |
| tree | 8d1361fc012bea4a95f685dfd4303312fa73c148 /clang/lib/Lex | |
| parent | cff2b27bf4e66d5a4728c893a81b382291fae68e (diff) | |
| download | bcm5719-llvm-f5f945280836dca2617c5d3848bcdeb9dbcab7de.tar.gz bcm5719-llvm-f5f945280836dca2617c5d3848bcdeb9dbcab7de.zip | |
Teach subframework header lookup to suggest modules <rdar://problem/13176200>.
llvm-svn: 174683
Diffstat (limited to 'clang/lib/Lex')
| -rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 23 | ||||
| -rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 7 |
2 files changed, 26 insertions, 4 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 3bf38e00cd5..3b6c5ccde4a 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -665,7 +665,8 @@ const FileEntry *HeaderSearch:: LookupSubframeworkHeader(StringRef Filename, const FileEntry *ContextFileEnt, SmallVectorImpl<char> *SearchPath, - SmallVectorImpl<char> *RelativePath) { + SmallVectorImpl<char> *RelativePath, + Module **SuggestedModule) { assert(ContextFileEnt && "No context file?"); // Framework names must have a '/' in the filename. Find it. @@ -754,6 +755,26 @@ LookupSubframeworkHeader(StringRef Filename, // of evaluation. unsigned DirInfo = getFileInfo(ContextFileEnt).DirInfo; getFileInfo(FE).DirInfo = DirInfo; + + // If we're supposed to suggest a module, look for one now. + if (SuggestedModule) { + // Find the top-level framework based on this framework. + FrameworkName.pop_back(); // remove the trailing '/' + SmallVector<std::string, 4> SubmodulePath; + const DirectoryEntry *TopFrameworkDir + = ::getTopFrameworkDir(FileMgr, FrameworkName, SubmodulePath); + + // Determine the name of the top-level framework. + StringRef ModuleName = llvm::sys::path::stem(TopFrameworkDir->getName()); + + // Load this framework module. If that succeeds, find the suggested module + // for this header, if any. + bool IsSystem = false; + if (loadFrameworkModule(ModuleName, TopFrameworkDir, IsSystem)) { + *SuggestedModule = findModuleForHeader(FE); + } + } + return FE; } diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 74376e47acb..3356637b20c 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -537,11 +537,11 @@ const FileEntry *Preprocessor::LookupFile( // Otherwise, see if this is a subframework header. If so, this is relative // to one of the headers on the #include stack. Walk the list of the current // headers on the #include stack and pass them to HeaderInfo. - // FIXME: SuggestedModule! if (IsFileLexer()) { if ((CurFileEnt = SourceMgr.getFileEntryForID(CurPPLexer->getFileID()))) if ((FE = HeaderInfo.LookupSubframeworkHeader(Filename, CurFileEnt, - SearchPath, RelativePath))) + SearchPath, RelativePath, + SuggestedModule))) return FE; } @@ -551,7 +551,8 @@ const FileEntry *Preprocessor::LookupFile( if ((CurFileEnt = SourceMgr.getFileEntryForID(ISEntry.ThePPLexer->getFileID()))) if ((FE = HeaderInfo.LookupSubframeworkHeader( - Filename, CurFileEnt, SearchPath, RelativePath))) + Filename, CurFileEnt, SearchPath, RelativePath, + SuggestedModule))) return FE; } } |

