summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-04-06 03:21:44 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-04-06 03:21:44 +0000
commit4382fe74bb5ddbca63caa33ba004dad98072094c (patch)
treea762868eac403a66f3df64fe1dec95566b9fb3de /clang/lib/Frontend/CompilerInstance.cpp
parent44ec0a7d76ce04ed6b5f792a00c043e2ac09a86a (diff)
downloadbcm5719-llvm-4382fe74bb5ddbca63caa33ba004dad98072094c.tar.gz
bcm5719-llvm-4382fe74bb5ddbca63caa33ba004dad98072094c.zip
[Frontend] If the module file lock owner have died, try to get the lock again. Needs llvm r205683.
llvm-svn: 205684
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp55
1 files changed, 33 insertions, 22 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index ce47674edbc..f12f6303f0d 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -770,31 +770,10 @@ static InputKind getSourceInputKindFromOptions(const LangOptions &LangOpts) {
/// \brief Compile a module file for the given module, using the options
/// provided by the importing compiler instance.
-static void compileModule(CompilerInstance &ImportingInstance,
+static void compileModuleImpl(CompilerInstance &ImportingInstance,
SourceLocation ImportLoc,
Module *Module,
StringRef ModuleFileName) {
- // FIXME: have LockFileManager return an error_code so that we can
- // avoid the mkdir when the directory already exists.
- StringRef Dir = llvm::sys::path::parent_path(ModuleFileName);
- llvm::sys::fs::create_directories(Dir);
-
- llvm::LockFileManager Locked(ModuleFileName);
- switch (Locked) {
- case llvm::LockFileManager::LFS_Error:
- return;
-
- case llvm::LockFileManager::LFS_Owned:
- // We're responsible for building the module ourselves. Do so below.
- break;
-
- case llvm::LockFileManager::LFS_Shared:
- // Someone else is responsible for building the module. Wait for them to
- // finish.
- Locked.waitForUnlock();
- return;
- }
-
ModuleMap &ModMap
= ImportingInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap();
@@ -914,6 +893,38 @@ static void compileModule(CompilerInstance &ImportingInstance,
}
}
+static void compileModule(CompilerInstance &ImportingInstance,
+ SourceLocation ImportLoc,
+ Module *Module,
+ StringRef ModuleFileName) {
+ // FIXME: have LockFileManager return an error_code so that we can
+ // avoid the mkdir when the directory already exists.
+ StringRef Dir = llvm::sys::path::parent_path(ModuleFileName);
+ llvm::sys::fs::create_directories(Dir);
+
+ while (1) {
+ llvm::LockFileManager Locked(ModuleFileName);
+ switch (Locked) {
+ case llvm::LockFileManager::LFS_Error:
+ return;
+
+ case llvm::LockFileManager::LFS_Owned:
+ // We're responsible for building the module ourselves. Do so below.
+ break;
+
+ case llvm::LockFileManager::LFS_Shared:
+ // Someone else is responsible for building the module. Wait for them to
+ // finish.
+ if (Locked.waitForUnlock() == llvm::LockFileManager::Res_OwnerDied)
+ continue; // try again to get the lock.
+ return;
+ }
+
+ return compileModuleImpl(ImportingInstance, ImportLoc, Module,
+ ModuleFileName);
+ }
+}
+
/// \brief Diagnose differences between the current definition of the given
/// configuration macro and the definition provided on the command line.
static void checkConfigMacro(Preprocessor &PP, StringRef ConfigMacro,
OpenPOWER on IntegriCloud