]> granicus.if.org Git - clang/commitdiff
Start refactoring to use module maps when rebuilding a module
authorDouglas Gregor <dgregor@apple.com>
Tue, 29 Nov 2011 18:31:39 +0000 (18:31 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 29 Nov 2011 18:31:39 +0000 (18:31 +0000)
on-the-fly. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145414 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/CompilerInstance.cpp

index d1db46c4e188c6d846bdc2b08636418bfb21ab95..c6a55839848d0163c5e88749edbe016571eaa6a1 100644 (file)
@@ -962,9 +962,13 @@ void LockFileManager::waitForUnlock() {
 /// umbrella header, using the options provided by the importing compiler
 /// instance.
 static void compileModule(CompilerInstance &ImportingInstance,
-                          StringRef ModuleName,
-                          StringRef ModuleFileName,
-                          StringRef UmbrellaHeader) {
+                          ModuleMap::Module *Module,
+                          StringRef ModuleFileName) {
+  // FIXME: Currently, we can only handle modules that have an umbrella 
+  // header. That's lame.
+  if (!Module->UmbrellaHeader)
+    return;
+  
   LockFileManager Locked(ModuleFileName);
   switch (Locked) {
   case LockFileManager::LFS_Error:
@@ -991,11 +995,12 @@ static void compileModule(CompilerInstance &ImportingInstance,
   Invocation->getPreprocessorOpts().resetNonModularOptions();
 
   // Note the name of the module we're building.
-  Invocation->getLangOpts()->CurrentModule = ModuleName;
+  Invocation->getLangOpts()->CurrentModule = Module->getTopLevelModuleName();
 
   // Note that this module is part of the module build path, so that we
   // can detect cycles in the module graph.
-  Invocation->getPreprocessorOpts().ModuleBuildPath.push_back(ModuleName);
+  Invocation->getPreprocessorOpts().ModuleBuildPath
+    .push_back(Module->getTopLevelModuleName());
 
   // Set up the inputs/outputs so that we build the module from its umbrella
   // header.
@@ -1005,7 +1010,7 @@ static void compileModule(CompilerInstance &ImportingInstance,
   FrontendOpts.Inputs.clear();
   FrontendOpts.Inputs.push_back(
     std::make_pair(getSourceInputKindFromOptions(*Invocation->getLangOpts()),
-                                                 UmbrellaHeader));
+                                           Module->UmbrellaHeader->getName()));
 
   Invocation->getDiagnosticOpts().VerifyDiagnostics = 0;
 
@@ -1052,10 +1057,9 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
                                              &ModuleFileName);
 
   bool BuildingModule = false;
-  if (!ModuleFile && Module && Module->UmbrellaHeader) {
-    // We didn't find the module, but there is an umbrella header that
-    // can be used to create the module file. Create a separate compilation
-    // module to do so.
+  if (!ModuleFile && Module) {
+    // The module is not cached, but we have a module map from which we can
+    // build the module.
 
     // Check whether there is a cycle in the module graph.
     SmallVectorImpl<std::string> &ModuleBuildPath
@@ -1079,8 +1083,7 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
     getDiagnostics().Report(ModuleNameLoc, diag::warn_module_build)
       << ModuleName.getName();
     BuildingModule = true;
-    compileModule(*this, ModuleName.getName(), ModuleFileName, 
-                  Module->UmbrellaHeader->getName());
+    compileModule(*this, Module, ModuleFileName);
     ModuleFile = FileMgr->getFile(ModuleFileName);
   }