mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Extract validateTBDIfNeeded.
This commit is contained in:
@@ -1095,6 +1095,31 @@ static bool processCommandLineAndRunImmediately(CompilerInvocation &Invocation,
|
|||||||
return Instance.getASTContext().hadError();
|
return Instance.getASTContext().hadError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool validateTBDIfNeeded(CompilerInvocation &Invocation,
|
||||||
|
ModuleOrSourceFile MSF,
|
||||||
|
bool astGuaranteedToCorrespondToSIL,
|
||||||
|
llvm::Module &IRModule) {
|
||||||
|
if (!astGuaranteedToCorrespondToSIL ||
|
||||||
|
!inputFileKindCanHaveTBDValidated(Invocation.getInputKind()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const auto mode = Invocation.getFrontendOptions().ValidateTBDAgainstIR;
|
||||||
|
// Ensure all cases are covered by using a switch here.
|
||||||
|
switch (mode) {
|
||||||
|
case FrontendOptions::TBDValidationMode::None:
|
||||||
|
return false;
|
||||||
|
case FrontendOptions::TBDValidationMode::All:
|
||||||
|
case FrontendOptions::TBDValidationMode::MissingFromTBD:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const auto hasMultipleIGMs = Invocation.getSILOptions().hasMultipleIGMs();
|
||||||
|
const bool allSymbols = mode == FrontendOptions::TBDValidationMode::All;
|
||||||
|
return MSF.is<SourceFile *>() ? validateTBD(MSF.get<SourceFile *>(), IRModule,
|
||||||
|
hasMultipleIGMs, allSymbols)
|
||||||
|
: validateTBD(MSF.get<ModuleDecl *>(), IRModule,
|
||||||
|
hasMultipleIGMs, allSymbols);
|
||||||
|
}
|
||||||
|
|
||||||
static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
|
static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
|
||||||
CompilerInvocation &Invocation,
|
CompilerInvocation &Invocation,
|
||||||
std::unique_ptr<SILModule> SM,
|
std::unique_ptr<SILModule> SM,
|
||||||
@@ -1256,35 +1281,9 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
|
|||||||
return HadError;
|
return HadError;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool allSymbols = false;
|
if (validateTBDIfNeeded(Invocation, MSF, astGuaranteedToCorrespondToSIL,
|
||||||
switch (opts.ValidateTBDAgainstIR) {
|
*IRModule))
|
||||||
case FrontendOptions::TBDValidationMode::None:
|
return true;
|
||||||
break;
|
|
||||||
case FrontendOptions::TBDValidationMode::All:
|
|
||||||
allSymbols = true;
|
|
||||||
LLVM_FALLTHROUGH;
|
|
||||||
case FrontendOptions::TBDValidationMode::MissingFromTBD: {
|
|
||||||
if (!inputFileKindCanHaveTBDValidated(Invocation.getInputKind()) ||
|
|
||||||
!astGuaranteedToCorrespondToSIL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
const auto &SILOpts = Invocation.getSILOptions();
|
|
||||||
const auto hasMultipleIGMs = SILOpts.hasMultipleIGMs();
|
|
||||||
bool error;
|
|
||||||
if (MSF.is<SourceFile*>())
|
|
||||||
error = validateTBD(MSF.get<SourceFile*>(),
|
|
||||||
*IRModule, hasMultipleIGMs,
|
|
||||||
allSymbols);
|
|
||||||
else
|
|
||||||
error = validateTBD(MSF.get<ModuleDecl*>(),
|
|
||||||
*IRModule, hasMultipleIGMs,
|
|
||||||
allSymbols);
|
|
||||||
if (error)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<llvm::TargetMachine> TargetMachine =
|
std::unique_ptr<llvm::TargetMachine> TargetMachine =
|
||||||
createTargetMachine(IRGenOpts, Context);
|
createTargetMachine(IRGenOpts, Context);
|
||||||
|
|||||||
Reference in New Issue
Block a user