forked from OSchip/llvm-project
Ensure that all module build failures get diagnosed
Otherwise we can end up silently skipping an import. If we happen to be building another module at the time, we may build a mysteriously broken module and not know why it seems to be missing symbols. llvm-svn: 218552
This commit is contained in:
parent
2b91a7f80f
commit
d213aab71d
|
@ -81,6 +81,8 @@ def err_deleted_non_function : Error<
|
||||||
"only functions can have deleted definitions">;
|
"only functions can have deleted definitions">;
|
||||||
def err_module_not_found : Error<"module '%0' not found">, DefaultFatal;
|
def err_module_not_found : Error<"module '%0' not found">, DefaultFatal;
|
||||||
def err_module_not_built : Error<"could not build module '%0'">, DefaultFatal;
|
def err_module_not_built : Error<"could not build module '%0'">, DefaultFatal;
|
||||||
|
def err_module_lock_failure : Error<
|
||||||
|
"could not acquire lock file for module '%0'">, DefaultFatal;
|
||||||
def err_module_cycle : Error<"cyclic dependency in module '%0': %1">,
|
def err_module_cycle : Error<"cyclic dependency in module '%0': %1">,
|
||||||
DefaultFatal;
|
DefaultFatal;
|
||||||
def note_pragma_entered_here : Note<"#pragma entered here">;
|
def note_pragma_entered_here : Note<"#pragma entered here">;
|
||||||
|
|
|
@ -990,9 +990,10 @@ static bool compileAndLoadModule(CompilerInstance &ImportingInstance,
|
||||||
SourceLocation ImportLoc,
|
SourceLocation ImportLoc,
|
||||||
SourceLocation ModuleNameLoc, Module *Module,
|
SourceLocation ModuleNameLoc, Module *Module,
|
||||||
StringRef ModuleFileName) {
|
StringRef ModuleFileName) {
|
||||||
|
DiagnosticsEngine &Diags = ImportingInstance.getDiagnostics();
|
||||||
|
|
||||||
auto diagnoseBuildFailure = [&] {
|
auto diagnoseBuildFailure = [&] {
|
||||||
ImportingInstance.getDiagnostics().Report(ModuleNameLoc,
|
Diags.Report(ModuleNameLoc, diag::err_module_not_built)
|
||||||
diag::err_module_not_built)
|
|
||||||
<< Module->Name << SourceRange(ImportLoc, ModuleNameLoc);
|
<< Module->Name << SourceRange(ImportLoc, ModuleNameLoc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1006,6 +1007,8 @@ static bool compileAndLoadModule(CompilerInstance &ImportingInstance,
|
||||||
llvm::LockFileManager Locked(ModuleFileName);
|
llvm::LockFileManager Locked(ModuleFileName);
|
||||||
switch (Locked) {
|
switch (Locked) {
|
||||||
case llvm::LockFileManager::LFS_Error:
|
case llvm::LockFileManager::LFS_Error:
|
||||||
|
Diags.Report(ModuleNameLoc, diag::err_module_lock_failure)
|
||||||
|
<< Module->Name;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case llvm::LockFileManager::LFS_Owned:
|
case llvm::LockFileManager::LFS_Owned:
|
||||||
|
@ -1040,6 +1043,10 @@ static bool compileAndLoadModule(CompilerInstance &ImportingInstance,
|
||||||
continue;
|
continue;
|
||||||
} else if (ReadResult == ASTReader::Missing) {
|
} else if (ReadResult == ASTReader::Missing) {
|
||||||
diagnoseBuildFailure();
|
diagnoseBuildFailure();
|
||||||
|
} else if (ReadResult != ASTReader::Success &&
|
||||||
|
!Diags.hasErrorOccurred()) {
|
||||||
|
// The ASTReader didn't diagnose the error, so conservatively report it.
|
||||||
|
diagnoseBuildFailure();
|
||||||
}
|
}
|
||||||
return ReadResult == ASTReader::Success;
|
return ReadResult == ASTReader::Success;
|
||||||
}
|
}
|
||||||
|
@ -1362,6 +1369,8 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
|
||||||
// Try to compile and then load the module.
|
// Try to compile and then load the module.
|
||||||
if (!compileAndLoadModule(*this, ImportLoc, ModuleNameLoc, Module,
|
if (!compileAndLoadModule(*this, ImportLoc, ModuleNameLoc, Module,
|
||||||
ModuleFileName)) {
|
ModuleFileName)) {
|
||||||
|
assert(getDiagnostics().hasErrorOccurred() &&
|
||||||
|
"undiagnosed error in compileAndLoadModule");
|
||||||
if (getPreprocessorOpts().FailedModules)
|
if (getPreprocessorOpts().FailedModules)
|
||||||
getPreprocessorOpts().FailedModules->addFailed(ModuleName);
|
getPreprocessorOpts().FailedModules->addFailed(ModuleName);
|
||||||
KnownModules[Path[0].first] = nullptr;
|
KnownModules[Path[0].first] = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue