r181643 - [Modules] Make r180934 more efficient by only loading top-level module maps in system header directories.
Douglas Gregor
dgregor at apple.com
Fri May 10 15:52:28 PDT 2013
Author: dgregor
Date: Fri May 10 17:52:27 2013
New Revision: 181643
URL: http://llvm.org/viewvc/llvm-project?rev=181643&view=rev
Log:
[Modules] Make r180934 more efficient by only loading top-level module maps in system header directories.
Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=181643&r1=181642&r2=181643&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Fri May 10 17:52:27 2013
@@ -492,7 +492,10 @@ public:
///
/// \param Modules Will be filled with the set of known, top-level modules.
void collectAllModules(SmallVectorImpl<Module *> &Modules);
-
+
+ /// \brief Load all known, top-level system modules.
+ void loadTopLevelSystemModules();
+
private:
/// \brief Retrieve a module with the given name, which may be part of the
/// given framework.
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=181643&r1=181642&r2=181643&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri May 10 17:52:27 2013
@@ -1146,6 +1146,20 @@ void HeaderSearch::collectAllModules(Sma
}
}
+void HeaderSearch::loadTopLevelSystemModules() {
+ // Load module maps for each of the header search directories.
+ for (unsigned Idx = 0, N = SearchDirs.size(); Idx != N; ++Idx) {
+ // We only care about normal system header directories.
+ if (!SearchDirs[Idx].isNormalDir() ||
+ SearchDirs[Idx].getDirCharacteristic() != SrcMgr::C_System) {
+ continue;
+ }
+
+ // Try to load a module map file for the search directory.
+ loadModuleMapFile(SearchDirs[Idx].getDir());
+ }
+}
+
void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
if (SearchDir.haveSearchedAllModuleMaps())
return;
Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=181643&r1=181642&r2=181643&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri May 10 17:52:27 2013
@@ -183,8 +183,7 @@ Module *ModuleMap::findModuleForHeader(c
// specific module (e.g., in /usr/include).
if (File->getDir() == BuiltinIncludeDir &&
isBuiltinHeader(llvm::sys::path::filename(File->getName()))) {
- SmallVector<Module *, 4> AllModules;
- HeaderInfo.collectAllModules(AllModules);
+ HeaderInfo.loadTopLevelSystemModules();
// Check again.
Known = Headers.find(File);
More information about the cfe-commits
mailing list