mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #60139 from artemcm/AddConstValueExtractionPathHandling
Add supplementary output path handling for extracted compile-time-known values
This commit is contained in:
@@ -654,6 +654,11 @@ bool ArgsToFrontendOptionsConverter::checkUnusedSupplementaryOutputPaths()
|
||||
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_abi_descriptor);
|
||||
return true;
|
||||
}
|
||||
if (!FrontendOptions::canActionEmitConstValues(Opts.RequestedAction) &&
|
||||
Opts.InputsAndOutputs.hasConstValuesOutputPath()) {
|
||||
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_const_values);
|
||||
return true;
|
||||
}
|
||||
if (!FrontendOptions::canActionEmitModuleSemanticInfo(Opts.RequestedAction) &&
|
||||
Opts.InputsAndOutputs.hasModuleSemanticInfoOutputPath()) {
|
||||
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_module_semantic_info);
|
||||
|
||||
@@ -335,6 +335,8 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
|
||||
options::OPT_emit_module_summary_path);
|
||||
auto abiDescriptorOutput = getSupplementaryFilenamesFromArguments(
|
||||
options::OPT_emit_abi_descriptor_path);
|
||||
auto constValuesOutput = getSupplementaryFilenamesFromArguments(
|
||||
options::OPT_emit_const_values_path);
|
||||
auto moduleSemanticInfoOutput = getSupplementaryFilenamesFromArguments(
|
||||
options::OPT_emit_module_semantic_info_path);
|
||||
auto optRecordOutput = getSupplementaryFilenamesFromArguments(
|
||||
@@ -367,6 +369,7 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
|
||||
sop.ModuleSourceInfoOutputPath = (*moduleSourceInfoOutput)[i];
|
||||
sop.ModuleSummaryOutputPath = (*moduleSummaryOutput)[i];
|
||||
sop.ABIDescriptorOutputPath = (*abiDescriptorOutput)[i];
|
||||
sop.ConstValuesOutputPath = (*constValuesOutput)[i];
|
||||
sop.ModuleSemanticInfoOutputPath = (*moduleSemanticInfoOutput)[i];
|
||||
sop.YAMLOptRecordPath = (*optRecordOutput)[i];
|
||||
sop.BitstreamOptRecordPath = (*optRecordOutput)[i];
|
||||
@@ -426,6 +429,12 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
|
||||
file_types::TY_SwiftDeps, "",
|
||||
defaultSupplementaryOutputPathExcludingExtension);
|
||||
|
||||
auto constValuesOutputPath = determineSupplementaryOutputFilename(
|
||||
OPT_emit_const_values,
|
||||
pathsFromArguments.ConstValuesOutputPath,
|
||||
file_types::TY_ConstValues, "",
|
||||
defaultSupplementaryOutputPathExcludingExtension);
|
||||
|
||||
auto serializedDiagnosticsPath = determineSupplementaryOutputFilename(
|
||||
OPT_serialize_diagnostics, pathsFromArguments.SerializedDiagnosticsPath,
|
||||
file_types::TY_SerializedDiagnostics, "",
|
||||
@@ -470,7 +479,9 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
|
||||
|
||||
// There is no non-path form of -emit-abi-descriptor-path
|
||||
auto ABIDescriptorOutputPath = pathsFromArguments.ABIDescriptorOutputPath;
|
||||
// There is no non-path form of -emit-module-semantic-info-path
|
||||
auto ModuleSemanticInfoOutputPath = pathsFromArguments.ModuleSemanticInfoOutputPath;
|
||||
|
||||
ID emitModuleOption;
|
||||
std::string moduleExtension;
|
||||
std::string mainOutputIfUsableForModule;
|
||||
@@ -506,6 +517,7 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
|
||||
sop.ModuleSourceInfoOutputPath = moduleSourceInfoOutputPath;
|
||||
sop.ModuleSummaryOutputPath = moduleSummaryOutputPath;
|
||||
sop.ABIDescriptorOutputPath = ABIDescriptorOutputPath;
|
||||
sop.ConstValuesOutputPath = constValuesOutputPath;
|
||||
sop.ModuleSemanticInfoOutputPath = ModuleSemanticInfoOutputPath;
|
||||
sop.YAMLOptRecordPath = YAMLOptRecordPath;
|
||||
sop.BitstreamOptRecordPath = bitstreamOptRecordPath;
|
||||
@@ -594,6 +606,7 @@ createFromTypeToPathMap(const TypeToPathMap *map) {
|
||||
{file_types::TY_YAMLOptRecord, paths.YAMLOptRecordPath},
|
||||
{file_types::TY_BitstreamOptRecord, paths.BitstreamOptRecordPath},
|
||||
{file_types::TY_SwiftABIDescriptor, paths.ABIDescriptorOutputPath},
|
||||
{file_types::TY_ConstValues, paths.ConstValuesOutputPath}
|
||||
};
|
||||
for (const std::pair<file_types::ID, std::string &> &typeAndString :
|
||||
typesAndStrings) {
|
||||
|
||||
@@ -1350,6 +1350,9 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts,
|
||||
if (const Arg *A = Args.getLastArg(OPT_batch_scan_input_file))
|
||||
Opts.BatchScanInputFilePath = A->getValue();
|
||||
|
||||
if (const Arg *A = Args.getLastArg(OPT_const_gather_protocols_file))
|
||||
Opts.ConstGatherProtocolListFilePath = A->getValue();
|
||||
|
||||
for (auto A : Args.getAllArgValues(options::OPT_serialized_path_obfuscate)) {
|
||||
auto SplitMap = StringRef(A).split('=');
|
||||
Opts.DeserializedPathRecoverer.addMapping(SplitMap.first, SplitMap.second);
|
||||
|
||||
@@ -105,6 +105,11 @@ std::string CompilerInvocation::getReferenceDependenciesFilePathForPrimary(
|
||||
return getPrimarySpecificPathsForPrimary(filename)
|
||||
.SupplementaryOutputs.ReferenceDependenciesFilePath;
|
||||
}
|
||||
std::string CompilerInvocation::getConstValuesFilePathForPrimary(
|
||||
StringRef filename) const {
|
||||
return getPrimarySpecificPathsForPrimary(filename)
|
||||
.SupplementaryOutputs.ConstValuesOutputPath;
|
||||
}
|
||||
std::string
|
||||
CompilerInvocation::getSerializedDiagnosticsPathForAtMostOnePrimary() const {
|
||||
return getPrimarySpecificPathsForAtMostOnePrimary()
|
||||
|
||||
@@ -509,6 +509,12 @@ bool FrontendInputsAndOutputs::hasABIDescriptorOutputPath() const {
|
||||
return outs.ABIDescriptorOutputPath;
|
||||
});
|
||||
}
|
||||
bool FrontendInputsAndOutputs::hasConstValuesOutputPath() const {
|
||||
return hasSupplementaryOutputPath(
|
||||
[](const SupplementaryOutputPaths &outs) -> const std::string & {
|
||||
return outs.ConstValuesOutputPath;
|
||||
});
|
||||
}
|
||||
bool FrontendInputsAndOutputs::hasModuleSemanticInfoOutputPath() const {
|
||||
return hasSupplementaryOutputPath(
|
||||
[](const SupplementaryOutputPaths &outs) -> const std::string & {
|
||||
|
||||
@@ -582,6 +582,48 @@ bool FrontendOptions::canActionEmitABIDescriptor(ActionType action) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool FrontendOptions::canActionEmitConstValues(ActionType action) {
|
||||
switch (action) {
|
||||
case ActionType::NoneAction:
|
||||
case ActionType::Parse:
|
||||
case ActionType::ResolveImports:
|
||||
case ActionType::DumpParse:
|
||||
case ActionType::DumpInterfaceHash:
|
||||
case ActionType::DumpAST:
|
||||
case ActionType::EmitSyntax:
|
||||
case ActionType::PrintAST:
|
||||
case ActionType::PrintASTDecl:
|
||||
case ActionType::DumpScopeMaps:
|
||||
case ActionType::DumpTypeRefinementContexts:
|
||||
case ActionType::DumpTypeInfo:
|
||||
case ActionType::CompileModuleFromInterface:
|
||||
case ActionType::TypecheckModuleFromInterface:
|
||||
case ActionType::Immediate:
|
||||
case ActionType::REPL:
|
||||
case ActionType::EmitPCM:
|
||||
case ActionType::DumpPCM:
|
||||
case ActionType::ScanDependencies:
|
||||
case ActionType::PrintVersion:
|
||||
case ActionType::PrintFeature:
|
||||
return false;
|
||||
case ActionType::Typecheck:
|
||||
case ActionType::MergeModules:
|
||||
case ActionType::EmitModuleOnly:
|
||||
case ActionType::EmitPCH:
|
||||
case ActionType::EmitSILGen:
|
||||
case ActionType::EmitSIL:
|
||||
case ActionType::EmitSIBGen:
|
||||
case ActionType::EmitSIB:
|
||||
case ActionType::EmitIRGen:
|
||||
case ActionType::EmitIR:
|
||||
case ActionType::EmitBC:
|
||||
case ActionType::EmitAssembly:
|
||||
case ActionType::EmitObject:
|
||||
case ActionType::EmitImportedModules:
|
||||
return true;
|
||||
}
|
||||
llvm_unreachable("unhandled action");
|
||||
}
|
||||
bool FrontendOptions::canActionEmitModule(ActionType action) {
|
||||
switch (action) {
|
||||
case ActionType::NoneAction:
|
||||
|
||||
Reference in New Issue
Block a user