Revert "Merge pull request #41831 from hyp/unify-header"

This reverts commit cd93d23bac, reversing
changes made to f9f5476e9a.
This commit is contained in:
Alex Lorenz
2022-03-18 10:03:07 -07:00
parent cd93d23bac
commit 4c9582c295
29 changed files with 226 additions and 163 deletions

View File

@@ -170,22 +170,36 @@ static bool writeSIL(SILModule &SM, const PrimarySpecificPaths &PSPs,
/// Prints the Objective-C "generated header" interface for \p M to \p
/// outputPath.
/// Print the exposed "generated header" interface for \p M to \p
///
/// ...unless \p outputPath is empty, in which case it does nothing.
///
/// \returns true if there were any errors
///
/// \see swift::printAsObjC
static bool printAsObjCIfNeeded(StringRef outputPath, ModuleDecl *M,
StringRef bridgingHeader) {
if (outputPath.empty())
return false;
return withOutputFile(M->getDiags(), outputPath,
[&](raw_ostream &out) -> bool {
return printAsObjC(out, M, bridgingHeader);
});
}
/// Prints the C++ "generated header" interface for \p M to \p
/// outputPath.
///
/// ...unless \p outputPath is empty, in which case it does nothing.
///
/// \returns true if there were any errors
///
/// \see swift::printAsClangHeader
static bool printAsClangHeaderIfNeeded(StringRef outputPath, ModuleDecl *M,
StringRef bridgingHeader) {
/// \see swift::printAsCXX
static bool printAsCxxIfNeeded(StringRef outputPath, ModuleDecl *M) {
if (outputPath.empty())
return false;
return withOutputFile(M->getDiags(), outputPath,
[&](raw_ostream &out) -> bool {
return printAsClangHeader(out, M, bridgingHeader);
});
return withOutputFile(
M->getDiags(), outputPath,
[&](raw_ostream &os) -> bool { return printAsCXX(os, M); });
}
/// Prints the stable module interface for \p M to \p outputPath.
@@ -810,7 +824,7 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
bool hadAnyError = false;
if ((!Context.hadError() || opts.AllowModuleWithCompilerErrors) &&
opts.InputsAndOutputs.hasClangHeaderOutputPath()) {
opts.InputsAndOutputs.hasObjCHeaderOutputPath()) {
std::string BridgingHeaderPathForPrint;
if (!opts.ImplicitObjCHeaderPath.empty()) {
if (opts.BridgingHeaderDirForPrint.hasValue()) {
@@ -824,10 +838,16 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
BridgingHeaderPathForPrint = opts.ImplicitObjCHeaderPath;
}
}
hadAnyError |= printAsClangHeaderIfNeeded(
Invocation.getClangHeaderOutputPathForAtMostOnePrimary(),
hadAnyError |= printAsObjCIfNeeded(
Invocation.getObjCHeaderOutputPathForAtMostOnePrimary(),
Instance.getMainModule(), BridgingHeaderPathForPrint);
}
if ((!Context.hadError() || opts.AllowModuleWithCompilerErrors) &&
opts.InputsAndOutputs.hasCxxHeaderOutputPath()) {
hadAnyError |= printAsCxxIfNeeded(
Invocation.getCxxHeaderOutputPathForAtMostOnePrimary(),
Instance.getMainModule());
}
// Only want the header if there's been any errors, ie. there's not much
// point outputting a swiftinterface for an invalid module