Merge pull request #41831 from hyp/unify-header

[cxx-interop] start emitting a unified header file for a Swift module
This commit is contained in:
Alex Lorenz
2022-03-17 14:04:57 -07:00
committed by GitHub
29 changed files with 163 additions and 226 deletions

View File

@@ -59,8 +59,7 @@ TYPE("raw-sib", RawSIB, "sib", "")
TYPE("llvm-ir", LLVM_IR, "ll", "")
TYPE("llvm-bc", LLVM_BC, "bc", "")
TYPE("diagnostics", SerializedDiagnostics, "dia", "")
TYPE("objc-header", ObjCHeader, "h", "")
TYPE("cxx-header", CXXHeader, "h", "")
TYPE("clang-header", ClangHeader, "h", "")
TYPE("swift-dependencies", SwiftDeps, "swiftdeps", "")
TYPE("external-swift-dependencies", ExternalSwiftDeps, "swiftdeps.external", "")
TYPE("remap", Remapping, "remap", "")

View File

@@ -20,7 +20,8 @@
namespace swift {
struct SupplementaryOutputPaths {
/// The path to which we should emit an Objective-C header for the module.
/// The path to which we should emit a header file that exposes the Swift
/// declarations to C, Objective-C and C++ clients for the module.
///
/// Currently only makes sense when the compiler has whole module knowledge.
/// The modes for which it makes sense incuide both WMO and the "merge
@@ -28,19 +29,8 @@ struct SupplementaryOutputPaths {
/// the header is emitted in single-file mode, since it needs whole-module
/// information.
///
/// \sa swift::printAsObjC
std::string ObjCHeaderOutputPath;
/// The path to which we should emit a C++ header for the module.
///
/// Currently only makes sense when the compiler has whole module knowledge.
/// The modes for which it makes sense include both WMO and the "merge
/// modules" job that happens after the normal compilation jobs. That's where
/// the header is emitted in single-file mode, since it needs whole-module
/// information.
///
/// \sa swift::printAsCXX
std::string CxxHeaderOutputPath;
/// \sa swift::printAsClangHeader
std::string ClangHeaderOutputPath;
/// The path to which we should emit a serialized module.
/// It is valid whenever there are any inputs.
@@ -170,10 +160,8 @@ struct SupplementaryOutputPaths {
/// Apply a given function for each existing (non-empty string) supplementary output
void forEachSetOutput(llvm::function_ref<void(const std::string&)> fn) const {
if (!ObjCHeaderOutputPath.empty())
fn(ObjCHeaderOutputPath);
if (!CxxHeaderOutputPath.empty())
fn(CxxHeaderOutputPath);
if (!ClangHeaderOutputPath.empty())
fn(ClangHeaderOutputPath);
if (!ModuleOutputPath.empty())
fn(ModuleOutputPath);
if (!ModuleSourceInfoOutputPath.empty())
@@ -209,9 +197,8 @@ struct SupplementaryOutputPaths {
}
bool empty() const {
return ObjCHeaderOutputPath.empty() && CxxHeaderOutputPath.empty() &&
ModuleOutputPath.empty() && ModuleDocOutputPath.empty() &&
DependenciesFilePath.empty() &&
return ClangHeaderOutputPath.empty() && ModuleOutputPath.empty() &&
ModuleDocOutputPath.empty() && DependenciesFilePath.empty() &&
ReferenceDependenciesFilePath.empty() &&
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&