Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ static bool readASTAfterCompileModule(CompilerInstance &ImportingInstance,
SourceLocation ImportLoc,
SourceLocation ModuleNameLoc,
Module *Module, StringRef ModuleFileName,
bool *OutOfDate) {
bool *OutOfDate, bool *Missing) {
DiagnosticsEngine &Diags = ImportingInstance.getDiagnostics();

unsigned ModuleLoadCapabilities = ASTReader::ARR_Missing;
Expand All @@ -1427,6 +1427,12 @@ static bool readASTAfterCompileModule(CompilerInstance &ImportingInstance,
return false;
}

// The caller wants to handle missing module files.
if (Missing && ReadResult == ASTReader::Missing) {
*Missing = true;
return false;
}

// The ASTReader didn't diagnose the error, so conservatively report it.
if (ReadResult == ASTReader::Missing || !Diags.hasErrorOccurred())
Diags.Report(ModuleNameLoc, diag::err_module_not_built)
Expand All @@ -1452,7 +1458,7 @@ static bool compileModuleAndReadASTImpl(CompilerInstance &ImportingInstance,

return readASTAfterCompileModule(ImportingInstance, ImportLoc, ModuleNameLoc,
Module, ModuleFileName,
/*OutOfDate=*/nullptr);
/*OutOfDate=*/nullptr, /*Missing=*/nullptr);
}

/// Compile a module in a separate compiler instance and read the AST,
Expand Down Expand Up @@ -1517,15 +1523,17 @@ static bool compileModuleAndReadASTBehindLock(

// Read the module that was just written by someone else.
bool OutOfDate = false;
bool Missing = false;
if (readASTAfterCompileModule(ImportingInstance, ImportLoc, ModuleNameLoc,
Module, ModuleFileName, &OutOfDate))
Module, ModuleFileName, &OutOfDate, &Missing))
return true;
if (!OutOfDate)
if (!OutOfDate && !Missing)
return false;

// The module may be out of date in the presence of file system races,
// or if one of its imports depends on header search paths that are not
// consistent with this ImportingInstance. Try again...
// The module may be missing or out of date in the presence of file system
// races. It may also be out of date if one of its imports depends on header
// search paths that are not consistent with this ImportingInstance.
// Try again...
}
}

Expand Down
13 changes: 6 additions & 7 deletions llvm/include/llvm/Support/LockFileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
namespace llvm {
class StringRef;

/// Class that manages the creation of a lock file to aid
/// implicit coordination between different processes.
/// Class that manages the creation of a lock file to aid implicit coordination
/// between different processes.
///
/// The implicit coordination works by creating a ".lock" file alongside
/// the file that we're coordinating for, using the atomicity of the file
/// system to ensure that only a single process can create that ".lock" file.
/// When the lock file is removed, the owning process has finished the
/// operation.
/// The implicit coordination works by creating a ".lock" file, using the
/// atomicity of the file system to ensure that only a single process can create
/// that ".lock" file. When the lock file is removed, the owning process has
/// finished the operation.
class LockFileManager {
public:
/// Describes the state of a lock file.
Expand Down
6 changes: 1 addition & 5 deletions llvm/lib/Support/LockFileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,8 @@ LockFileManager::waitForUnlock(const unsigned MaxSeconds) {
while (Backoff.waitForNextAttempt()) {
// FIXME: implement event-based waiting
if (sys::fs::access(LockFileName.c_str(), sys::fs::AccessMode::Exist) ==
errc::no_such_file_or_directory) {
// If the original file wasn't created, somone thought the lock was dead.
if (!sys::fs::exists(FileName))
return Res_OwnerDied;
errc::no_such_file_or_directory)
return Res_Success;
}

// If the process owning the lock died without cleaning up, just bail out.
if (!processStillExecuting((*Owner).first, (*Owner).second))
Expand Down