diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-11-07 17:46:15 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-11-07 17:46:15 +0000 |
commit | 188dbef26df3901195869ff19273323d657e995f (patch) | |
tree | bd511d7f3af88db0e1ada6ef900c9e72815459d3 /clang/lib/Frontend/CompilerInstance.cpp | |
parent | b9db60fbce070a0eef80de620ac59b2a1b8869ec (diff) | |
download | bcm5719-llvm-188dbef26df3901195869ff19273323d657e995f.tar.gz bcm5719-llvm-188dbef26df3901195869ff19273323d657e995f.zip |
When loading a module fails because it is out of date, rebuild that
module in place. <rdar://problem/10138913>
llvm-svn: 167539
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index b85832208b5..576ca94e74d 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -762,7 +762,7 @@ static void compileModule(CompilerInstance &ImportingInstance, // Someone else is responsible for building the module. Wait for them to // finish. Locked.waitForUnlock(); - break; + return; } ModuleMap &ModMap @@ -975,13 +975,36 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc, } // Try to load the module we found. + unsigned ARRFlags = ASTReader::ARR_None; + if (Module) + ARRFlags |= ASTReader::ARR_OutOfDate; switch (ModuleManager->ReadAST(ModuleFile->getName(), serialization::MK_Module, - ASTReader::ARR_None)) { + ARRFlags)) { case ASTReader::Success: break; - case ASTReader::OutOfDate: + case ASTReader::OutOfDate: { + // The module file is out-of-date. Rebuild it. + getFileManager().invalidateCache(ModuleFile); + bool Existed; + llvm::sys::fs::remove(ModuleFileName, Existed); + compileModule(*this, Module, ModuleFileName); + + // Try loading the module again. + ModuleFile = FileMgr->getFile(ModuleFileName); + if (!ModuleFile || + ModuleManager->ReadAST(ModuleFileName, + serialization::MK_Module, + ASTReader::ARR_None) != ASTReader::Success) { + KnownModules[Path[0].first] = 0; + return 0; + } + + // Okay, we've rebuilt and now loaded the module. + break; + } + case ASTReader::VersionMismatch: case ASTReader::ConfigurationMismatch: case ASTReader::HadErrors: |