[frontend] Fix TBD validation almost always done for modules

The logic to do or not the validation of TBD against IR was incorrect.
In the case of modules, the comment described what was supposed to
happen (skipping the validation if the module had SIB files), but the
code was returning if the module had or not SIB files, which would have
returned true for any module without SIB files without checking if the
compiler was build in a debug configuration or not.

This was only visible in the case of non-debug builds, and it only
appeared for us in a convoluted mix of optimized builds with
-enable-testing on some modules.
This commit is contained in:
Daniel Rodríguez Troitiño
2021-12-03 19:12:50 -08:00
committed by Daniel Rodríguez Troitiño
parent 2755f74eeb
commit 8a0e5129b1
2 changed files with 30 additions and 1 deletions

View File

@@ -1390,10 +1390,14 @@ static bool validateTBDIfNeeded(const CompilerInvocation &Invocation,
// may have serialized hand-crafted SIL definitions that are invisible to
// TBDGen as it is an AST-only traversal.
if (auto *mod = MSF.dyn_cast<ModuleDecl *>()) {
return llvm::none_of(mod->getFiles(), [](const FileUnit *File) -> bool {
bool hasSIB = llvm::any_of(mod->getFiles(), [](const FileUnit *File) -> bool {
auto SASTF = dyn_cast<SerializedASTFile>(File);
return SASTF && SASTF->isSIB();
});
if (hasSIB) {
return false;
}
}
// "Default" mode's behavior varies if using a debug compiler.