]> granicus.if.org Git - clang/commitdiff
[Modules] Make r180934 more efficient by only loading top-level module maps in system...
authorDouglas Gregor <dgregor@apple.com>
Fri, 10 May 2013 22:52:27 +0000 (22:52 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 10 May 2013 22:52:27 +0000 (22:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181643 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/HeaderSearch.h
lib/Lex/HeaderSearch.cpp
lib/Lex/ModuleMap.cpp

index 446a3810461f236c7937d3246ee6c2d8e24c2f6e..c46c8ce6ef019eb2d2b91ec5bdb6b0c19a3c9b6b 100644 (file)
@@ -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.
index b8556dde0b202416d165589cdd08630518e04d73..8a99ed298836135a88de7aef86771b9ca95366e2 100644 (file)
@@ -1146,6 +1146,20 @@ void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
   }
 }
 
+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;
index de234853fbf3793f12a40f8aef2183eedccbfe10..62b1fc73c8093c89a639ab0f305d65b9596e4bf3 100644 (file)
@@ -183,8 +183,7 @@ Module *ModuleMap::findModuleForHeader(const FileEntry *File) {
   // 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);