diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-29 18:31:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-29 18:31:39 +0000 |
commit | 6dc57927ea85c51a0adb8a781eb7c362fb7d7b13 (patch) | |
tree | 33cd4ef92bc778144eba88c8462e737e9af5fdfc /clang/lib/Frontend/CompilerInstance.cpp | |
parent | ca6f8ddbf8aa25af7bac1f2d55d6136e72ad132c (diff) | |
download | bcm5719-llvm-6dc57927ea85c51a0adb8a781eb7c362fb7d7b13.tar.gz bcm5719-llvm-6dc57927ea85c51a0adb8a781eb7c362fb7d7b13.zip |
Start refactoring to use module maps when rebuilding a module
on-the-fly. No functionality change.
llvm-svn: 145414
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index d1db46c4e18..c6a55839848 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -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); } |