diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-29 18:15:03 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-29 18:15:03 +0000 |
commit | 07f4357b446e959f81063bb14b705ea375b35ac4 (patch) | |
tree | df680b6e2b37529673a04a69a7c0389aa609ff2f /clang/lib/Lex/HeaderSearch.cpp | |
parent | 279a6c3747b10c33f8f425cf4a24e64db015d3e9 (diff) | |
download | bcm5719-llvm-07f4357b446e959f81063bb14b705ea375b35ac4.tar.gz bcm5719-llvm-07f4357b446e959f81063bb14b705ea375b35ac4.zip |
Implement code completion support for module import declarations, e.g.,
@import <complete with module names here>
or
@import std.<complete with submodule names here>
Addresses <rdar://problem/10710117>.
llvm-svn: 149199
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 7c981f852bc..e56eb6c915c 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -953,3 +953,58 @@ HeaderSearch::loadModuleMapFile(const DirectoryEntry *Dir) { return LMM_InvalidModuleMap; } +void HeaderSearch::collectAllModules(llvm::SmallVectorImpl<Module *> &Modules) { + Modules.clear(); + + // Load module maps for each of the header search directories. + for (unsigned Idx = 0, N = SearchDirs.size(); Idx != N; ++Idx) { + if (SearchDirs[Idx].isFramework()) { + llvm::error_code EC; + llvm::SmallString<128> DirNative; + llvm::sys::path::native(SearchDirs[Idx].getFrameworkDir()->getName(), + DirNative); + + // Search each of the ".framework" directories to load them as modules. + bool IsSystem = SearchDirs[Idx].getDirCharacteristic() != SrcMgr::C_User; + for (llvm::sys::fs::directory_iterator Dir(DirNative.str(), EC), DirEnd; + Dir != DirEnd && !EC; Dir.increment(EC)) { + if (llvm::sys::path::extension(Dir->path()) != ".framework") + continue; + + const DirectoryEntry *FrameworkDir = FileMgr.getDirectory(Dir->path()); + if (!FrameworkDir) + continue; + + // Load this framework module. + loadFrameworkModule(llvm::sys::path::stem(Dir->path()), FrameworkDir, + IsSystem); + } + continue; + } + + // FIXME: Deal with header maps. + if (SearchDirs[Idx].isHeaderMap()) + continue; + + // Try to load a module map file for the search directory. + loadModuleMapFile(SearchDirs[Idx].getDir()); + + // Try to load module map files for immediate subdirectories of this search + // directory. + llvm::error_code EC; + llvm::SmallString<128> DirNative; + llvm::sys::path::native(SearchDirs[Idx].getDir()->getName(), DirNative); + for (llvm::sys::fs::directory_iterator Dir(DirNative.str(), EC), DirEnd; + Dir != DirEnd && !EC; Dir.increment(EC)) { + loadModuleMapFile(Dir->path()); + } + } + + // Populate the list of modules. + for (ModuleMap::module_iterator M = ModMap.module_begin(), + MEnd = ModMap.module_end(); + M != MEnd; ++M) { + Modules.push_back(M->getValue()); + } +} + |