Skip to content

Commit b4e5e78

Browse files
[SupplementaryOutputs][NFC] Simplify boilerplate output checks.
Reduce some boilerplate code to check if supplementary outputs exist.
1 parent b98d7a5 commit b4e5e78

File tree

4 files changed

+13
-131
lines changed

4 files changed

+13
-131
lines changed

Diff for: include/swift/Frontend/FrontendInputsAndOutputs.h

+9-18
Original file line numberDiff line numberDiff line change
@@ -259,24 +259,15 @@ class FrontendInputsAndOutputs {
259259
llvm::function_ref<const std::string &(const SupplementaryOutputPaths &)>
260260
extractorFn) const;
261261

262-
bool hasDependenciesPath() const;
263-
bool hasReferenceDependenciesPath() const;
264-
bool hasClangHeaderOutputPath() const;
265-
bool hasLoadedModuleTracePath() const;
266-
bool hasModuleOutputPath() const;
267-
bool hasModuleDocOutputPath() const;
268-
bool hasModuleSourceInfoOutputPath() const;
269-
bool hasModuleInterfaceOutputPath() const;
270-
bool hasPrivateModuleInterfaceOutputPath() const;
271-
bool hasPackageModuleInterfaceOutputPath() const;
272-
bool hasABIDescriptorOutputPath() const;
273-
bool hasAPIDescriptorOutputPath() const;
274-
bool hasConstValuesOutputPath() const;
275-
bool hasModuleSemanticInfoOutputPath() const;
276-
bool hasModuleSummaryOutputPath() const;
277-
bool hasTBDPath() const;
278-
bool hasYAMLOptRecordPath() const;
279-
bool hasBitstreamOptRecordPath() const;
262+
#define OUTPUT(NAME, TYPE) \
263+
bool has##NAME() const { \
264+
return hasSupplementaryOutputPath( \
265+
[](const SupplementaryOutputPaths &outs) -> const std::string & { \
266+
return outs.NAME; \
267+
}); \
268+
}
269+
#include "swift/Basic/SupplementaryOutputPaths.def"
270+
#undef OUTPUT
280271

281272
bool hasDependencyTrackerPath() const;
282273
};

Diff for: lib/Frontend/ArgsToFrontendOptionsConverter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,12 @@ bool ArgsToFrontendOptionsConverter::checkBuildFromInterfaceOnlyOptions()
750750
bool ArgsToFrontendOptionsConverter::checkUnusedSupplementaryOutputPaths()
751751
const {
752752
if (!FrontendOptions::canActionEmitDependencies(Opts.RequestedAction) &&
753-
Opts.InputsAndOutputs.hasDependenciesPath()) {
753+
Opts.InputsAndOutputs.hasDependenciesFilePath()) {
754754
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_dependencies);
755755
return true;
756756
}
757757
if (!FrontendOptions::canActionEmitReferenceDependencies(Opts.RequestedAction)
758-
&& Opts.InputsAndOutputs.hasReferenceDependenciesPath()) {
758+
&& Opts.InputsAndOutputs.hasReferenceDependenciesFilePath()) {
759759
Diags.diagnose(SourceLoc(),
760760
diag::error_mode_cannot_emit_reference_dependencies);
761761
return true;

Diff for: lib/Frontend/FrontendInputsAndOutputs.cpp

+1-110
Original file line numberDiff line numberDiff line change
@@ -464,117 +464,8 @@ bool FrontendInputsAndOutputs::hasSupplementaryOutputPath(
464464
});
465465
}
466466

467-
bool FrontendInputsAndOutputs::hasDependenciesPath() const {
468-
return hasSupplementaryOutputPath(
469-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
470-
return outs.DependenciesFilePath;
471-
});
472-
}
473-
bool FrontendInputsAndOutputs::hasReferenceDependenciesPath() const {
474-
return hasSupplementaryOutputPath(
475-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
476-
return outs.ReferenceDependenciesFilePath;
477-
});
478-
}
479-
bool FrontendInputsAndOutputs::hasClangHeaderOutputPath() const {
480-
return hasSupplementaryOutputPath(
481-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
482-
return outs.ClangHeaderOutputPath;
483-
});
484-
}
485-
bool FrontendInputsAndOutputs::hasLoadedModuleTracePath() const {
486-
return hasSupplementaryOutputPath(
487-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
488-
return outs.LoadedModuleTracePath;
489-
});
490-
}
491-
bool FrontendInputsAndOutputs::hasModuleOutputPath() const {
492-
return hasSupplementaryOutputPath(
493-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
494-
return outs.ModuleOutputPath;
495-
});
496-
}
497-
bool FrontendInputsAndOutputs::hasModuleDocOutputPath() const {
498-
return hasSupplementaryOutputPath(
499-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
500-
return outs.ModuleDocOutputPath;
501-
});
502-
}
503-
bool FrontendInputsAndOutputs::hasModuleSourceInfoOutputPath() const {
504-
return hasSupplementaryOutputPath(
505-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
506-
return outs.ModuleSourceInfoOutputPath;
507-
});
508-
}
509-
bool FrontendInputsAndOutputs::hasModuleInterfaceOutputPath() const {
510-
return hasSupplementaryOutputPath(
511-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
512-
return outs.ModuleInterfaceOutputPath;
513-
});
514-
}
515-
bool FrontendInputsAndOutputs::hasPrivateModuleInterfaceOutputPath() const {
516-
return hasSupplementaryOutputPath(
517-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
518-
return outs.PrivateModuleInterfaceOutputPath;
519-
});
520-
}
521-
bool FrontendInputsAndOutputs::hasPackageModuleInterfaceOutputPath() const {
522-
return hasSupplementaryOutputPath(
523-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
524-
return outs.PackageModuleInterfaceOutputPath;
525-
});
526-
}
527-
bool FrontendInputsAndOutputs::hasABIDescriptorOutputPath() const {
528-
return hasSupplementaryOutputPath(
529-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
530-
return outs.ABIDescriptorOutputPath;
531-
});
532-
}
533-
bool FrontendInputsAndOutputs::hasAPIDescriptorOutputPath() const {
534-
return hasSupplementaryOutputPath(
535-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
536-
return outs.APIDescriptorOutputPath;
537-
});
538-
}
539-
bool FrontendInputsAndOutputs::hasConstValuesOutputPath() const {
540-
return hasSupplementaryOutputPath(
541-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
542-
return outs.ConstValuesOutputPath;
543-
});
544-
}
545-
bool FrontendInputsAndOutputs::hasModuleSemanticInfoOutputPath() const {
546-
return hasSupplementaryOutputPath(
547-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
548-
return outs.ModuleSemanticInfoOutputPath;
549-
});
550-
}
551-
bool FrontendInputsAndOutputs::hasModuleSummaryOutputPath() const {
552-
return hasSupplementaryOutputPath(
553-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
554-
return outs.ModuleSummaryOutputPath;
555-
});
556-
}
557-
bool FrontendInputsAndOutputs::hasTBDPath() const {
558-
return hasSupplementaryOutputPath(
559-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
560-
return outs.TBDPath;
561-
});
562-
}
563-
bool FrontendInputsAndOutputs::hasYAMLOptRecordPath() const {
564-
return hasSupplementaryOutputPath(
565-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
566-
return outs.YAMLOptRecordPath;
567-
});
568-
}
569-
bool FrontendInputsAndOutputs::hasBitstreamOptRecordPath() const {
570-
return hasSupplementaryOutputPath(
571-
[](const SupplementaryOutputPaths &outs) -> const std::string & {
572-
return outs.BitstreamOptRecordPath;
573-
});
574-
}
575-
576467
bool FrontendInputsAndOutputs::hasDependencyTrackerPath() const {
577-
return hasDependenciesPath() || hasReferenceDependenciesPath() ||
468+
return hasDependenciesFilePath() || hasReferenceDependenciesFilePath() ||
578469
hasLoadedModuleTracePath();
579470
}
580471

Diff for: lib/FrontendTool/FrontendTool.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ static void emitSwiftdepsForAllPrimaryInputsIfNeeded(
664664
CompilerInstance &Instance) {
665665
const auto &Invocation = Instance.getInvocation();
666666
if (Invocation.getFrontendOptions()
667-
.InputsAndOutputs.hasReferenceDependenciesPath() &&
667+
.InputsAndOutputs.hasReferenceDependenciesFilePath() &&
668668
Instance.getPrimarySourceFiles().empty()) {
669669
Instance.getDiags().diagnose(
670670
SourceLoc(), diag::emit_reference_dependencies_without_primary_file);

0 commit comments

Comments
 (0)