mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Revert "Revert "Merge pull request #41831 from hyp/unify-header""
This reverts commit 4c9582c295.
This commit is contained in:
@@ -118,9 +118,7 @@ ERROR(error_mode_cannot_emit_dependencies,none,
|
|||||||
ERROR(error_mode_cannot_emit_reference_dependencies,none,
|
ERROR(error_mode_cannot_emit_reference_dependencies,none,
|
||||||
"this mode does not support emitting reference dependency files", ())
|
"this mode does not support emitting reference dependency files", ())
|
||||||
ERROR(error_mode_cannot_emit_header,none,
|
ERROR(error_mode_cannot_emit_header,none,
|
||||||
"this mode does not support emitting Objective-C headers", ())
|
"this mode does not support emitting Objective-C or C++ headers", ())
|
||||||
ERROR(error_mode_cannot_emit_cxx_header,none,
|
|
||||||
"this mode does not support emitting C++ headers", ())
|
|
||||||
ERROR(error_mode_cannot_emit_loaded_module_trace,none,
|
ERROR(error_mode_cannot_emit_loaded_module_trace,none,
|
||||||
"this mode does not support emitting the loaded module trace", ())
|
"this mode does not support emitting the loaded module trace", ())
|
||||||
ERROR(error_mode_cannot_emit_module,none,
|
ERROR(error_mode_cannot_emit_module,none,
|
||||||
|
|||||||
@@ -59,8 +59,7 @@ TYPE("raw-sib", RawSIB, "sib", "")
|
|||||||
TYPE("llvm-ir", LLVM_IR, "ll", "")
|
TYPE("llvm-ir", LLVM_IR, "ll", "")
|
||||||
TYPE("llvm-bc", LLVM_BC, "bc", "")
|
TYPE("llvm-bc", LLVM_BC, "bc", "")
|
||||||
TYPE("diagnostics", SerializedDiagnostics, "dia", "")
|
TYPE("diagnostics", SerializedDiagnostics, "dia", "")
|
||||||
TYPE("objc-header", ObjCHeader, "h", "")
|
TYPE("clang-header", ClangHeader, "h", "")
|
||||||
TYPE("cxx-header", CXXHeader, "h", "")
|
|
||||||
TYPE("swift-dependencies", SwiftDeps, "swiftdeps", "")
|
TYPE("swift-dependencies", SwiftDeps, "swiftdeps", "")
|
||||||
TYPE("external-swift-dependencies", ExternalSwiftDeps, "swiftdeps.external", "")
|
TYPE("external-swift-dependencies", ExternalSwiftDeps, "swiftdeps.external", "")
|
||||||
TYPE("remap", Remapping, "remap", "")
|
TYPE("remap", Remapping, "remap", "")
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
namespace swift {
|
namespace swift {
|
||||||
struct SupplementaryOutputPaths {
|
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.
|
/// Currently only makes sense when the compiler has whole module knowledge.
|
||||||
/// The modes for which it makes sense incuide both WMO and the "merge
|
/// 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
|
/// the header is emitted in single-file mode, since it needs whole-module
|
||||||
/// information.
|
/// information.
|
||||||
///
|
///
|
||||||
/// \sa swift::printAsObjC
|
/// \sa swift::printAsClangHeader
|
||||||
std::string ObjCHeaderOutputPath;
|
std::string ClangHeaderOutputPath;
|
||||||
|
|
||||||
/// 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;
|
|
||||||
|
|
||||||
/// The path to which we should emit a serialized module.
|
/// The path to which we should emit a serialized module.
|
||||||
/// It is valid whenever there are any inputs.
|
/// 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
|
/// Apply a given function for each existing (non-empty string) supplementary output
|
||||||
void forEachSetOutput(llvm::function_ref<void(const std::string&)> fn) const {
|
void forEachSetOutput(llvm::function_ref<void(const std::string&)> fn) const {
|
||||||
if (!ObjCHeaderOutputPath.empty())
|
if (!ClangHeaderOutputPath.empty())
|
||||||
fn(ObjCHeaderOutputPath);
|
fn(ClangHeaderOutputPath);
|
||||||
if (!CxxHeaderOutputPath.empty())
|
|
||||||
fn(CxxHeaderOutputPath);
|
|
||||||
if (!ModuleOutputPath.empty())
|
if (!ModuleOutputPath.empty())
|
||||||
fn(ModuleOutputPath);
|
fn(ModuleOutputPath);
|
||||||
if (!ModuleSourceInfoOutputPath.empty())
|
if (!ModuleSourceInfoOutputPath.empty())
|
||||||
@@ -209,9 +197,8 @@ struct SupplementaryOutputPaths {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const {
|
bool empty() const {
|
||||||
return ObjCHeaderOutputPath.empty() && CxxHeaderOutputPath.empty() &&
|
return ClangHeaderOutputPath.empty() && ModuleOutputPath.empty() &&
|
||||||
ModuleOutputPath.empty() && ModuleDocOutputPath.empty() &&
|
ModuleDocOutputPath.empty() && DependenciesFilePath.empty() &&
|
||||||
DependenciesFilePath.empty() &&
|
|
||||||
ReferenceDependenciesFilePath.empty() &&
|
ReferenceDependenciesFilePath.empty() &&
|
||||||
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
|
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
|
||||||
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
|
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
|
||||||
|
|||||||
@@ -392,8 +392,7 @@ public:
|
|||||||
|
|
||||||
std::string getOutputFilenameForAtMostOnePrimary() const;
|
std::string getOutputFilenameForAtMostOnePrimary() const;
|
||||||
std::string getMainInputFilenameForDebugInfoForAtMostOnePrimary() const;
|
std::string getMainInputFilenameForDebugInfoForAtMostOnePrimary() const;
|
||||||
std::string getObjCHeaderOutputPathForAtMostOnePrimary() const;
|
std::string getClangHeaderOutputPathForAtMostOnePrimary() const;
|
||||||
std::string getCxxHeaderOutputPathForAtMostOnePrimary() const;
|
|
||||||
std::string getModuleOutputPathForAtMostOnePrimary() const;
|
std::string getModuleOutputPathForAtMostOnePrimary() const;
|
||||||
std::string
|
std::string
|
||||||
getReferenceDependenciesFilePathForPrimary(StringRef filename) const;
|
getReferenceDependenciesFilePathForPrimary(StringRef filename) const;
|
||||||
|
|||||||
@@ -249,8 +249,7 @@ public:
|
|||||||
|
|
||||||
bool hasDependenciesPath() const;
|
bool hasDependenciesPath() const;
|
||||||
bool hasReferenceDependenciesPath() const;
|
bool hasReferenceDependenciesPath() const;
|
||||||
bool hasObjCHeaderOutputPath() const;
|
bool hasClangHeaderOutputPath() const;
|
||||||
bool hasCxxHeaderOutputPath() const;
|
|
||||||
bool hasLoadedModuleTracePath() const;
|
bool hasLoadedModuleTracePath() const;
|
||||||
bool hasModuleOutputPath() const;
|
bool hasModuleOutputPath() const;
|
||||||
bool hasModuleDocOutputPath() const;
|
bool hasModuleDocOutputPath() const;
|
||||||
|
|||||||
@@ -532,13 +532,11 @@ def emit_objc_header_path : Separate<["-"], "emit-objc-header-path">,
|
|||||||
SupplementaryOutput]>,
|
SupplementaryOutput]>,
|
||||||
MetaVarName<"<path>">, HelpText<"Emit an Objective-C header file to <path>">;
|
MetaVarName<"<path>">, HelpText<"Emit an Objective-C header file to <path>">;
|
||||||
|
|
||||||
def emit_cxx_header : Flag<["-"], "emit-cxx-header">,
|
def emit_clang_header_path : Separate<["-"], "emit-clang-header-path">,
|
||||||
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput]>,
|
Flags<[FrontendOption, NoDriverOption, NoInteractiveOption, ArgumentIsPath,
|
||||||
HelpText<"Emit a C++ header file">;
|
|
||||||
def emit_cxx_header_path : Separate<["-"], "emit-cxx-header-path">,
|
|
||||||
Flags<[FrontendOption, NoInteractiveOption, ArgumentIsPath,
|
|
||||||
SupplementaryOutput]>,
|
SupplementaryOutput]>,
|
||||||
MetaVarName<"<path>">, HelpText<"Emit a C++ header file to <path>">;
|
HelpText<"Emit an Objective-C and C++ header file to <path>">,
|
||||||
|
Alias<emit_objc_header_path>;
|
||||||
|
|
||||||
def static : Flag<["-"], "static">,
|
def static : Flag<["-"], "static">,
|
||||||
Flags<[FrontendOption, ModuleInterfaceOption, NoInteractiveOption]>,
|
Flags<[FrontendOption, ModuleInterfaceOption, NoInteractiveOption]>,
|
||||||
|
|||||||
@@ -21,16 +21,18 @@ namespace swift {
|
|||||||
class ModuleDecl;
|
class ModuleDecl;
|
||||||
class ValueDecl;
|
class ValueDecl;
|
||||||
|
|
||||||
/// Print the Objective-C-compatible declarations in a module as a Clang
|
/// Print the exposed declarations in a module into a Clang header.
|
||||||
/// header.
|
///
|
||||||
|
/// The Objective-C compatible declarations are printed into a block that
|
||||||
|
/// ensures that those declarations are only usable when the header is
|
||||||
|
/// compiled in Objective-C mode.
|
||||||
|
/// The C++ compatible declarations are printed into a block that ensures
|
||||||
|
/// that those declarations are only usable when the header is compiled in
|
||||||
|
/// C++ mode.
|
||||||
///
|
///
|
||||||
/// Returns true on error.
|
/// Returns true on error.
|
||||||
bool printAsObjC(raw_ostream &out, ModuleDecl *M, StringRef bridgingHeader);
|
bool printAsClangHeader(raw_ostream &out, ModuleDecl *M,
|
||||||
|
StringRef bridgingHeader);
|
||||||
/// Print the C++-compatible declarations in a module as a Clang header.
|
|
||||||
///
|
|
||||||
/// Returns true on error.
|
|
||||||
bool printAsCXX(raw_ostream &os, ModuleDecl *M);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ bool file_types::isTextual(ID Id) {
|
|||||||
case file_types::TY_ASTDump:
|
case file_types::TY_ASTDump:
|
||||||
case file_types::TY_RawSIL:
|
case file_types::TY_RawSIL:
|
||||||
case file_types::TY_LLVM_IR:
|
case file_types::TY_LLVM_IR:
|
||||||
case file_types::TY_ObjCHeader:
|
case file_types::TY_ClangHeader:
|
||||||
case file_types::TY_CXXHeader:
|
|
||||||
case file_types::TY_AutolinkFile:
|
case file_types::TY_AutolinkFile:
|
||||||
case file_types::TY_ImportedModules:
|
case file_types::TY_ImportedModules:
|
||||||
case file_types::TY_TBD:
|
case file_types::TY_TBD:
|
||||||
@@ -132,8 +131,7 @@ bool file_types::isAfterLLVM(ID Id) {
|
|||||||
case file_types::TY_Dependencies:
|
case file_types::TY_Dependencies:
|
||||||
case file_types::TY_ASTDump:
|
case file_types::TY_ASTDump:
|
||||||
case file_types::TY_RawSIL:
|
case file_types::TY_RawSIL:
|
||||||
case file_types::TY_ObjCHeader:
|
case file_types::TY_ClangHeader:
|
||||||
case file_types::TY_CXXHeader:
|
|
||||||
case file_types::TY_AutolinkFile:
|
case file_types::TY_AutolinkFile:
|
||||||
case file_types::TY_Image:
|
case file_types::TY_Image:
|
||||||
case file_types::TY_dSYM:
|
case file_types::TY_dSYM:
|
||||||
@@ -183,8 +181,7 @@ bool file_types::isPartOfSwiftCompilation(ID Id) {
|
|||||||
case file_types::TY_LLVM_BC:
|
case file_types::TY_LLVM_BC:
|
||||||
case file_types::TY_Object:
|
case file_types::TY_Object:
|
||||||
case file_types::TY_Dependencies:
|
case file_types::TY_Dependencies:
|
||||||
case file_types::TY_ObjCHeader:
|
case file_types::TY_ClangHeader:
|
||||||
case file_types::TY_CXXHeader:
|
|
||||||
case file_types::TY_AutolinkFile:
|
case file_types::TY_AutolinkFile:
|
||||||
case file_types::TY_PCH:
|
case file_types::TY_PCH:
|
||||||
case file_types::TY_ImportedModules:
|
case file_types::TY_ImportedModules:
|
||||||
|
|||||||
@@ -1981,8 +1981,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
|
|||||||
if (Arg *A = Args.getLastArg(options::OPT_import_objc_header)) {
|
if (Arg *A = Args.getLastArg(options::OPT_import_objc_header)) {
|
||||||
StringRef Value = A->getValue();
|
StringRef Value = A->getValue();
|
||||||
auto Ty = TC.lookupTypeForExtension(llvm::sys::path::extension(Value));
|
auto Ty = TC.lookupTypeForExtension(llvm::sys::path::extension(Value));
|
||||||
if (Ty == file_types::TY_ObjCHeader ||
|
if (Ty == file_types::TY_ClangHeader) {
|
||||||
Ty == file_types::TY_CXXHeader) {
|
|
||||||
auto *HeaderInput = C.createAction<InputAction>(*A, Ty);
|
auto *HeaderInput = C.createAction<InputAction>(*A, Ty);
|
||||||
StringRef PersistentPCHDir;
|
StringRef PersistentPCHDir;
|
||||||
if (const Arg *A = Args.getLastArg(options::OPT_pch_output_dir)) {
|
if (const Arg *A = Args.getLastArg(options::OPT_pch_output_dir)) {
|
||||||
@@ -2065,8 +2064,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
|
|||||||
case file_types::TY_LLVM_IR:
|
case file_types::TY_LLVM_IR:
|
||||||
case file_types::TY_LLVM_BC:
|
case file_types::TY_LLVM_BC:
|
||||||
case file_types::TY_SerializedDiagnostics:
|
case file_types::TY_SerializedDiagnostics:
|
||||||
case file_types::TY_ObjCHeader:
|
case file_types::TY_ClangHeader:
|
||||||
case file_types::TY_CXXHeader:
|
|
||||||
case file_types::TY_ClangModuleFile:
|
case file_types::TY_ClangModuleFile:
|
||||||
case file_types::TY_SwiftDeps:
|
case file_types::TY_SwiftDeps:
|
||||||
case file_types::TY_ExternalSwiftDeps:
|
case file_types::TY_ExternalSwiftDeps:
|
||||||
@@ -3480,12 +3478,12 @@ void Driver::chooseObjectiveCHeaderOutputPath(Compilation &C,
|
|||||||
StringRef workingDirectory,
|
StringRef workingDirectory,
|
||||||
CommandOutput *Output) const {
|
CommandOutput *Output) const {
|
||||||
|
|
||||||
if (hasExistingAdditionalOutput(*Output, file_types::TY_ObjCHeader))
|
if (hasExistingAdditionalOutput(*Output, file_types::TY_ClangHeader))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StringRef ObjCHeaderPath;
|
StringRef ObjCHeaderPath;
|
||||||
if (OutputMap) {
|
if (OutputMap) {
|
||||||
auto iter = OutputMap->find(file_types::TY_ObjCHeader);
|
auto iter = OutputMap->find(file_types::TY_ClangHeader);
|
||||||
if (iter != OutputMap->end())
|
if (iter != OutputMap->end())
|
||||||
ObjCHeaderPath = iter->second;
|
ObjCHeaderPath = iter->second;
|
||||||
}
|
}
|
||||||
@@ -3495,13 +3493,13 @@ void Driver::chooseObjectiveCHeaderOutputPath(Compilation &C,
|
|||||||
ObjCHeaderPath = A->getValue();
|
ObjCHeaderPath = A->getValue();
|
||||||
|
|
||||||
if (!ObjCHeaderPath.empty()) {
|
if (!ObjCHeaderPath.empty()) {
|
||||||
Output->setAdditionalOutputForType(file_types::TY_ObjCHeader,
|
Output->setAdditionalOutputForType(file_types::TY_ClangHeader,
|
||||||
ObjCHeaderPath);
|
ObjCHeaderPath);
|
||||||
} else {
|
} else {
|
||||||
// Put the header next to the primary output file.
|
// Put the header next to the primary output file.
|
||||||
// FIXME: That's not correct if the user /just/ passed -emit-header
|
// FIXME: That's not correct if the user /just/ passed -emit-header
|
||||||
// and not -emit-module.
|
// and not -emit-module.
|
||||||
addAuxiliaryOutput(C, *Output, file_types::TY_ObjCHeader,
|
addAuxiliaryOutput(C, *Output, file_types::TY_ClangHeader,
|
||||||
/*output file map*/ nullptr, workingDirectory);
|
/*output file map*/ nullptr, workingDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -675,8 +675,7 @@ const char *ToolChain::JobContext::computeFrontendModeForCompile() const {
|
|||||||
case file_types::TY_Dependencies:
|
case file_types::TY_Dependencies:
|
||||||
case file_types::TY_SwiftModuleDocFile:
|
case file_types::TY_SwiftModuleDocFile:
|
||||||
case file_types::TY_SerializedDiagnostics:
|
case file_types::TY_SerializedDiagnostics:
|
||||||
case file_types::TY_ObjCHeader:
|
case file_types::TY_ClangHeader:
|
||||||
case file_types::TY_CXXHeader:
|
|
||||||
case file_types::TY_Image:
|
case file_types::TY_Image:
|
||||||
case file_types::TY_SwiftDeps:
|
case file_types::TY_SwiftDeps:
|
||||||
case file_types::TY_ExternalSwiftDeps:
|
case file_types::TY_ExternalSwiftDeps:
|
||||||
@@ -815,7 +814,7 @@ void ToolChain::JobContext::addFrontendSupplementaryOutputArguments(
|
|||||||
file_types::TY_SerializedDiagnostics,
|
file_types::TY_SerializedDiagnostics,
|
||||||
"-serialize-diagnostics-path");
|
"-serialize-diagnostics-path");
|
||||||
|
|
||||||
if (addOutputsOfType(arguments, Output, Args, file_types::ID::TY_ObjCHeader,
|
if (addOutputsOfType(arguments, Output, Args, file_types::ID::TY_ClangHeader,
|
||||||
"-emit-objc-header-path")) {
|
"-emit-objc-header-path")) {
|
||||||
assert(OI.CompilerMode == OutputInfo::Mode::SingleCompile &&
|
assert(OI.CompilerMode == OutputInfo::Mode::SingleCompile &&
|
||||||
"The Swift tool should only emit an Obj-C header in single compile"
|
"The Swift tool should only emit an Obj-C header in single compile"
|
||||||
@@ -936,8 +935,7 @@ ToolChain::constructInvocation(const BackendJobAction &job,
|
|||||||
case file_types::TY_Dependencies:
|
case file_types::TY_Dependencies:
|
||||||
case file_types::TY_SwiftModuleDocFile:
|
case file_types::TY_SwiftModuleDocFile:
|
||||||
case file_types::TY_SerializedDiagnostics:
|
case file_types::TY_SerializedDiagnostics:
|
||||||
case file_types::TY_ObjCHeader:
|
case file_types::TY_ClangHeader:
|
||||||
case file_types::TY_CXXHeader:
|
|
||||||
case file_types::TY_Image:
|
case file_types::TY_Image:
|
||||||
case file_types::TY_SwiftDeps:
|
case file_types::TY_SwiftDeps:
|
||||||
case file_types::TY_ExternalSwiftDeps:
|
case file_types::TY_ExternalSwiftDeps:
|
||||||
@@ -1100,7 +1098,7 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
|
|||||||
file_types::TY_SerializedDiagnostics,
|
file_types::TY_SerializedDiagnostics,
|
||||||
"-serialize-diagnostics-path");
|
"-serialize-diagnostics-path");
|
||||||
addOutputsOfType(Arguments, context.Output, context.Args,
|
addOutputsOfType(Arguments, context.Output, context.Args,
|
||||||
file_types::TY_ObjCHeader, "-emit-objc-header-path");
|
file_types::TY_ClangHeader, "-emit-objc-header-path");
|
||||||
addOutputsOfType(Arguments, context.Output, context.Args, file_types::TY_TBD,
|
addOutputsOfType(Arguments, context.Output, context.Args, file_types::TY_TBD,
|
||||||
"-emit-tbd-path");
|
"-emit-tbd-path");
|
||||||
|
|
||||||
@@ -1309,7 +1307,7 @@ ToolChain::constructInvocation(const GeneratePCHJobAction &job,
|
|||||||
file_types::TY_SerializedDiagnostics,
|
file_types::TY_SerializedDiagnostics,
|
||||||
"-serialize-diagnostics-path");
|
"-serialize-diagnostics-path");
|
||||||
|
|
||||||
addInputsOfType(Arguments, context.InputActions, file_types::TY_ObjCHeader);
|
addInputsOfType(Arguments, context.InputActions, file_types::TY_ClangHeader);
|
||||||
context.Args.AddLastArg(Arguments, options::OPT_index_store_path);
|
context.Args.AddLastArg(Arguments, options::OPT_index_store_path);
|
||||||
|
|
||||||
if (job.isPersistentPCH()) {
|
if (job.isPersistentPCH()) {
|
||||||
|
|||||||
@@ -625,15 +625,10 @@ bool ArgsToFrontendOptionsConverter::checkUnusedSupplementaryOutputPaths()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!FrontendOptions::canActionEmitClangHeader(Opts.RequestedAction) &&
|
if (!FrontendOptions::canActionEmitClangHeader(Opts.RequestedAction) &&
|
||||||
Opts.InputsAndOutputs.hasObjCHeaderOutputPath()) {
|
Opts.InputsAndOutputs.hasClangHeaderOutputPath()) {
|
||||||
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_header);
|
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_header);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!FrontendOptions::canActionEmitClangHeader(Opts.RequestedAction) &&
|
|
||||||
Opts.InputsAndOutputs.hasCxxHeaderOutputPath()) {
|
|
||||||
Diags.diagnose(SourceLoc(), diag::error_mode_cannot_emit_cxx_header);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!FrontendOptions::canActionEmitLoadedModuleTrace(Opts.RequestedAction) &&
|
if (!FrontendOptions::canActionEmitLoadedModuleTrace(Opts.RequestedAction) &&
|
||||||
Opts.InputsAndOutputs.hasLoadedModuleTracePath()) {
|
Opts.InputsAndOutputs.hasLoadedModuleTracePath()) {
|
||||||
Diags.diagnose(SourceLoc(),
|
Diags.diagnose(SourceLoc(),
|
||||||
|
|||||||
@@ -308,10 +308,8 @@ Optional<std::vector<SupplementaryOutputPaths>>
|
|||||||
SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
|
SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
|
||||||
const {
|
const {
|
||||||
|
|
||||||
auto objCHeaderOutput = getSupplementaryFilenamesFromArguments(
|
auto clangHeaderOutput = getSupplementaryFilenamesFromArguments(
|
||||||
options::OPT_emit_objc_header_path);
|
options::OPT_emit_objc_header_path);
|
||||||
auto cxxHeaderOutput =
|
|
||||||
getSupplementaryFilenamesFromArguments(options::OPT_emit_cxx_header_path);
|
|
||||||
auto moduleOutput =
|
auto moduleOutput =
|
||||||
getSupplementaryFilenamesFromArguments(options::OPT_emit_module_path);
|
getSupplementaryFilenamesFromArguments(options::OPT_emit_module_path);
|
||||||
auto moduleDocOutput =
|
auto moduleDocOutput =
|
||||||
@@ -341,8 +339,8 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
|
|||||||
options::OPT_emit_module_semantic_info_path);
|
options::OPT_emit_module_semantic_info_path);
|
||||||
auto optRecordOutput = getSupplementaryFilenamesFromArguments(
|
auto optRecordOutput = getSupplementaryFilenamesFromArguments(
|
||||||
options::OPT_save_optimization_record_path);
|
options::OPT_save_optimization_record_path);
|
||||||
if (!objCHeaderOutput || !cxxHeaderOutput || !moduleOutput ||
|
if (!clangHeaderOutput || !moduleOutput || !moduleDocOutput ||
|
||||||
!moduleDocOutput || !dependenciesFile || !referenceDependenciesFile ||
|
!dependenciesFile || !referenceDependenciesFile ||
|
||||||
!serializedDiagnostics || !fixItsOutput || !loadedModuleTrace || !TBD ||
|
!serializedDiagnostics || !fixItsOutput || !loadedModuleTrace || !TBD ||
|
||||||
!moduleInterfaceOutput || !privateModuleInterfaceOutput ||
|
!moduleInterfaceOutput || !privateModuleInterfaceOutput ||
|
||||||
!moduleSourceInfoOutput || !moduleSummaryOutput || !abiDescriptorOutput ||
|
!moduleSourceInfoOutput || !moduleSummaryOutput || !abiDescriptorOutput ||
|
||||||
@@ -355,8 +353,7 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
|
|||||||
InputsAndOutputs.countOfFilesProducingSupplementaryOutput();
|
InputsAndOutputs.countOfFilesProducingSupplementaryOutput();
|
||||||
for (unsigned i = 0; i < N; ++i) {
|
for (unsigned i = 0; i < N; ++i) {
|
||||||
SupplementaryOutputPaths sop;
|
SupplementaryOutputPaths sop;
|
||||||
sop.ObjCHeaderOutputPath = (*objCHeaderOutput)[i];
|
sop.ClangHeaderOutputPath = (*clangHeaderOutput)[i];
|
||||||
sop.CxxHeaderOutputPath = (*cxxHeaderOutput)[i];
|
|
||||||
sop.ModuleOutputPath = (*moduleOutput)[i];
|
sop.ModuleOutputPath = (*moduleOutput)[i];
|
||||||
sop.ModuleDocOutputPath = (*moduleDocOutput)[i];
|
sop.ModuleDocOutputPath = (*moduleDocOutput)[i];
|
||||||
sop.DependenciesFilePath = (*dependenciesFile)[i];
|
sop.DependenciesFilePath = (*dependenciesFile)[i];
|
||||||
@@ -437,14 +434,9 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
|
|||||||
// There is no non-path form of -emit-fixits-path
|
// There is no non-path form of -emit-fixits-path
|
||||||
auto fixItsOutputPath = pathsFromArguments.FixItsOutputPath;
|
auto fixItsOutputPath = pathsFromArguments.FixItsOutputPath;
|
||||||
|
|
||||||
auto objcHeaderOutputPath = determineSupplementaryOutputFilename(
|
auto clangHeaderOutputPath = determineSupplementaryOutputFilename(
|
||||||
OPT_emit_objc_header, pathsFromArguments.ObjCHeaderOutputPath,
|
OPT_emit_objc_header, pathsFromArguments.ClangHeaderOutputPath,
|
||||||
file_types::TY_ObjCHeader, "",
|
file_types::TY_ClangHeader, "",
|
||||||
defaultSupplementaryOutputPathExcludingExtension);
|
|
||||||
|
|
||||||
auto cxxHeaderOutputPath = determineSupplementaryOutputFilename(
|
|
||||||
OPT_emit_cxx_header, pathsFromArguments.CxxHeaderOutputPath,
|
|
||||||
file_types::TY_CXXHeader, "",
|
|
||||||
defaultSupplementaryOutputPathExcludingExtension);
|
defaultSupplementaryOutputPathExcludingExtension);
|
||||||
|
|
||||||
auto loadedModuleTracePath = determineSupplementaryOutputFilename(
|
auto loadedModuleTracePath = determineSupplementaryOutputFilename(
|
||||||
@@ -500,8 +492,7 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
|
|||||||
defaultSupplementaryOutputPathExcludingExtension);
|
defaultSupplementaryOutputPathExcludingExtension);
|
||||||
|
|
||||||
SupplementaryOutputPaths sop;
|
SupplementaryOutputPaths sop;
|
||||||
sop.ObjCHeaderOutputPath = objcHeaderOutputPath;
|
sop.ClangHeaderOutputPath = clangHeaderOutputPath;
|
||||||
sop.CxxHeaderOutputPath = cxxHeaderOutputPath;
|
|
||||||
sop.ModuleOutputPath = moduleOutputPath;
|
sop.ModuleOutputPath = moduleOutputPath;
|
||||||
sop.ModuleDocOutputPath = moduleDocOutputPath;
|
sop.ModuleDocOutputPath = moduleDocOutputPath;
|
||||||
sop.DependenciesFilePath = dependenciesFilePath;
|
sop.DependenciesFilePath = dependenciesFilePath;
|
||||||
@@ -586,8 +577,7 @@ createFromTypeToPathMap(const TypeToPathMap *map) {
|
|||||||
if (!map)
|
if (!map)
|
||||||
return paths;
|
return paths;
|
||||||
const std::pair<file_types::ID, std::string &> typesAndStrings[] = {
|
const std::pair<file_types::ID, std::string &> typesAndStrings[] = {
|
||||||
{file_types::TY_ObjCHeader, paths.ObjCHeaderOutputPath},
|
{file_types::TY_ClangHeader, paths.ClangHeaderOutputPath},
|
||||||
{file_types::TY_CXXHeader, paths.CxxHeaderOutputPath},
|
|
||||||
{file_types::TY_SwiftModuleFile, paths.ModuleOutputPath},
|
{file_types::TY_SwiftModuleFile, paths.ModuleOutputPath},
|
||||||
{file_types::TY_SwiftModuleDocFile, paths.ModuleDocOutputPath},
|
{file_types::TY_SwiftModuleDocFile, paths.ModuleDocOutputPath},
|
||||||
{file_types::TY_SwiftSourceInfoFile, paths.ModuleSourceInfoOutputPath},
|
{file_types::TY_SwiftSourceInfoFile, paths.ModuleSourceInfoOutputPath},
|
||||||
@@ -615,9 +605,9 @@ createFromTypeToPathMap(const TypeToPathMap *map) {
|
|||||||
|
|
||||||
Optional<std::vector<SupplementaryOutputPaths>>
|
Optional<std::vector<SupplementaryOutputPaths>>
|
||||||
SupplementaryOutputPathsComputer::readSupplementaryOutputFileMap() const {
|
SupplementaryOutputPathsComputer::readSupplementaryOutputFileMap() const {
|
||||||
if (Arg *A = Args.getLastArg(
|
if (Arg *A = Args.getLastArg(options::OPT_emit_objc_header_path,
|
||||||
options::OPT_emit_objc_header_path, options::OPT_emit_cxx_header_path,
|
options::OPT_emit_module_path,
|
||||||
options::OPT_emit_module_path, options::OPT_emit_module_doc_path,
|
options::OPT_emit_module_doc_path,
|
||||||
options::OPT_emit_dependencies_path,
|
options::OPT_emit_dependencies_path,
|
||||||
options::OPT_emit_reference_dependencies_path,
|
options::OPT_emit_reference_dependencies_path,
|
||||||
options::OPT_serialize_diagnostics_path,
|
options::OPT_serialize_diagnostics_path,
|
||||||
|
|||||||
@@ -92,14 +92,9 @@ CompilerInvocation::getMainInputFilenameForDebugInfoForAtMostOnePrimary()
|
|||||||
.MainInputFilenameForDebugInfo;
|
.MainInputFilenameForDebugInfo;
|
||||||
}
|
}
|
||||||
std::string
|
std::string
|
||||||
CompilerInvocation::getObjCHeaderOutputPathForAtMostOnePrimary() const {
|
CompilerInvocation::getClangHeaderOutputPathForAtMostOnePrimary() const {
|
||||||
return getPrimarySpecificPathsForAtMostOnePrimary()
|
return getPrimarySpecificPathsForAtMostOnePrimary()
|
||||||
.SupplementaryOutputs.ObjCHeaderOutputPath;
|
.SupplementaryOutputs.ClangHeaderOutputPath;
|
||||||
}
|
|
||||||
std::string
|
|
||||||
CompilerInvocation::getCxxHeaderOutputPathForAtMostOnePrimary() const {
|
|
||||||
return getPrimarySpecificPathsForAtMostOnePrimary()
|
|
||||||
.SupplementaryOutputs.CxxHeaderOutputPath;
|
|
||||||
}
|
}
|
||||||
std::string CompilerInvocation::getModuleOutputPathForAtMostOnePrimary() const {
|
std::string CompilerInvocation::getModuleOutputPathForAtMostOnePrimary() const {
|
||||||
return getPrimarySpecificPathsForAtMostOnePrimary()
|
return getPrimarySpecificPathsForAtMostOnePrimary()
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ bool FrontendInputsAndOutputs::shouldTreatAsObjCHeader() const {
|
|||||||
if (hasSingleInput()) {
|
if (hasSingleInput()) {
|
||||||
StringRef InputExt = llvm::sys::path::extension(getFilenameOfFirstInput());
|
StringRef InputExt = llvm::sys::path::extension(getFilenameOfFirstInput());
|
||||||
switch (file_types::lookupTypeForExtension(InputExt)) {
|
switch (file_types::lookupTypeForExtension(InputExt)) {
|
||||||
case file_types::TY_ObjCHeader:
|
case file_types::TY_ClangHeader:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -461,16 +461,10 @@ bool FrontendInputsAndOutputs::hasReferenceDependenciesPath() const {
|
|||||||
return outs.ReferenceDependenciesFilePath;
|
return outs.ReferenceDependenciesFilePath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
bool FrontendInputsAndOutputs::hasObjCHeaderOutputPath() const {
|
bool FrontendInputsAndOutputs::hasClangHeaderOutputPath() const {
|
||||||
return hasSupplementaryOutputPath(
|
return hasSupplementaryOutputPath(
|
||||||
[](const SupplementaryOutputPaths &outs) -> const std::string & {
|
[](const SupplementaryOutputPaths &outs) -> const std::string & {
|
||||||
return outs.ObjCHeaderOutputPath;
|
return outs.ClangHeaderOutputPath;
|
||||||
});
|
|
||||||
}
|
|
||||||
bool FrontendInputsAndOutputs::hasCxxHeaderOutputPath() const {
|
|
||||||
return hasSupplementaryOutputPath(
|
|
||||||
[](const SupplementaryOutputPaths &outs) -> const std::string & {
|
|
||||||
return outs.CxxHeaderOutputPath;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
bool FrontendInputsAndOutputs::hasLoadedModuleTracePath() const {
|
bool FrontendInputsAndOutputs::hasLoadedModuleTracePath() const {
|
||||||
|
|||||||
@@ -234,8 +234,7 @@ void FrontendOptions::forAllOutputPaths(
|
|||||||
const std::string *outputs[] = {
|
const std::string *outputs[] = {
|
||||||
&outs.ModuleOutputPath, &outs.ModuleDocOutputPath,
|
&outs.ModuleOutputPath, &outs.ModuleDocOutputPath,
|
||||||
&outs.ModuleInterfaceOutputPath, &outs.PrivateModuleInterfaceOutputPath,
|
&outs.ModuleInterfaceOutputPath, &outs.PrivateModuleInterfaceOutputPath,
|
||||||
&outs.ObjCHeaderOutputPath, &outs.CxxHeaderOutputPath,
|
&outs.ClangHeaderOutputPath, &outs.ModuleSourceInfoOutputPath};
|
||||||
&outs.ModuleSourceInfoOutputPath};
|
|
||||||
for (const std::string *next : outputs) {
|
for (const std::string *next : outputs) {
|
||||||
if (!next->empty())
|
if (!next->empty())
|
||||||
fn(*next);
|
fn(*next);
|
||||||
|
|||||||
@@ -170,36 +170,22 @@ static bool writeSIL(SILModule &SM, const PrimarySpecificPaths &PSPs,
|
|||||||
|
|
||||||
/// Prints the Objective-C "generated header" interface for \p M to \p
|
/// Prints the Objective-C "generated header" interface for \p M to \p
|
||||||
/// outputPath.
|
/// 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.
|
/// outputPath.
|
||||||
///
|
///
|
||||||
/// ...unless \p outputPath is empty, in which case it does nothing.
|
/// ...unless \p outputPath is empty, in which case it does nothing.
|
||||||
///
|
///
|
||||||
/// \returns true if there were any errors
|
/// \returns true if there were any errors
|
||||||
///
|
///
|
||||||
/// \see swift::printAsCXX
|
/// \see swift::printAsClangHeader
|
||||||
static bool printAsCxxIfNeeded(StringRef outputPath, ModuleDecl *M) {
|
static bool printAsClangHeaderIfNeeded(StringRef outputPath, ModuleDecl *M,
|
||||||
|
StringRef bridgingHeader) {
|
||||||
if (outputPath.empty())
|
if (outputPath.empty())
|
||||||
return false;
|
return false;
|
||||||
return withOutputFile(
|
return withOutputFile(M->getDiags(), outputPath,
|
||||||
M->getDiags(), outputPath,
|
[&](raw_ostream &out) -> bool {
|
||||||
[&](raw_ostream &os) -> bool { return printAsCXX(os, M); });
|
return printAsClangHeader(out, M, bridgingHeader);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints the stable module interface for \p M to \p outputPath.
|
/// Prints the stable module interface for \p M to \p outputPath.
|
||||||
@@ -824,7 +810,7 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
|
|||||||
bool hadAnyError = false;
|
bool hadAnyError = false;
|
||||||
|
|
||||||
if ((!Context.hadError() || opts.AllowModuleWithCompilerErrors) &&
|
if ((!Context.hadError() || opts.AllowModuleWithCompilerErrors) &&
|
||||||
opts.InputsAndOutputs.hasObjCHeaderOutputPath()) {
|
opts.InputsAndOutputs.hasClangHeaderOutputPath()) {
|
||||||
std::string BridgingHeaderPathForPrint;
|
std::string BridgingHeaderPathForPrint;
|
||||||
if (!opts.ImplicitObjCHeaderPath.empty()) {
|
if (!opts.ImplicitObjCHeaderPath.empty()) {
|
||||||
if (opts.BridgingHeaderDirForPrint.hasValue()) {
|
if (opts.BridgingHeaderDirForPrint.hasValue()) {
|
||||||
@@ -838,16 +824,10 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
|
|||||||
BridgingHeaderPathForPrint = opts.ImplicitObjCHeaderPath;
|
BridgingHeaderPathForPrint = opts.ImplicitObjCHeaderPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hadAnyError |= printAsObjCIfNeeded(
|
hadAnyError |= printAsClangHeaderIfNeeded(
|
||||||
Invocation.getObjCHeaderOutputPathForAtMostOnePrimary(),
|
Invocation.getClangHeaderOutputPathForAtMostOnePrimary(),
|
||||||
Instance.getMainModule(), BridgingHeaderPathForPrint);
|
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
|
// Only want the header if there's been any errors, ie. there's not much
|
||||||
// point outputting a swiftinterface for an invalid module
|
// point outputting a swiftinterface for an invalid module
|
||||||
|
|||||||
@@ -26,9 +26,8 @@
|
|||||||
|
|
||||||
using namespace swift;
|
using namespace swift;
|
||||||
|
|
||||||
static void writePrologue(raw_ostream &out, ASTContext &ctx,
|
static void emitCxxConditional(raw_ostream &out,
|
||||||
StringRef macroGuard) {
|
llvm::function_ref<void()> cxxCase,
|
||||||
auto emitCxxConditional = [&](llvm::function_ref<void()> cxxCase,
|
|
||||||
llvm::function_ref<void()> cCase = {}) {
|
llvm::function_ref<void()> cCase = {}) {
|
||||||
out << "#if defined(__cplusplus)\n";
|
out << "#if defined(__cplusplus)\n";
|
||||||
cxxCase();
|
cxxCase();
|
||||||
@@ -37,8 +36,10 @@ static void writePrologue(raw_ostream &out, ASTContext &ctx,
|
|||||||
cCase();
|
cCase();
|
||||||
}
|
}
|
||||||
out << "#endif\n";
|
out << "#endif\n";
|
||||||
};
|
}
|
||||||
auto emitObjCConditional = [&](llvm::function_ref<void()> objcCase,
|
|
||||||
|
static void emitObjCConditional(raw_ostream &out,
|
||||||
|
llvm::function_ref<void()> objcCase,
|
||||||
llvm::function_ref<void()> nonObjCCase = {}) {
|
llvm::function_ref<void()> nonObjCCase = {}) {
|
||||||
out << "#if defined(__OBJC__)\n";
|
out << "#if defined(__OBJC__)\n";
|
||||||
objcCase();
|
objcCase();
|
||||||
@@ -47,7 +48,10 @@ static void writePrologue(raw_ostream &out, ASTContext &ctx,
|
|||||||
nonObjCCase();
|
nonObjCCase();
|
||||||
}
|
}
|
||||||
out << "#endif\n";
|
out << "#endif\n";
|
||||||
};
|
}
|
||||||
|
|
||||||
|
static void writePrologue(raw_ostream &out, ASTContext &ctx,
|
||||||
|
StringRef macroGuard) {
|
||||||
|
|
||||||
out << "// Generated by "
|
out << "// Generated by "
|
||||||
<< version::getSwiftFullVersion(ctx.LangOpts.EffectiveLanguageVersion)
|
<< version::getSwiftFullVersion(ctx.LangOpts.EffectiveLanguageVersion)
|
||||||
@@ -77,8 +81,10 @@ static void writePrologue(raw_ostream &out, ASTContext &ctx,
|
|||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#pragma clang diagnostic ignored \"-Wauto-import\"\n";
|
"#pragma clang diagnostic ignored \"-Wauto-import\"\n";
|
||||||
emitObjCConditional([&] { out << "#include <Foundation/Foundation.h>\n"; });
|
emitObjCConditional(out,
|
||||||
|
[&] { out << "#include <Foundation/Foundation.h>\n"; });
|
||||||
emitCxxConditional(
|
emitCxxConditional(
|
||||||
|
out,
|
||||||
[&] {
|
[&] {
|
||||||
out << "#include <cstdint>\n"
|
out << "#include <cstdint>\n"
|
||||||
"#include <cstddef>\n"
|
"#include <cstddef>\n"
|
||||||
@@ -276,7 +282,7 @@ static void writePrologue(raw_ostream &out, ASTContext &ctx,
|
|||||||
"#else\n"
|
"#else\n"
|
||||||
"# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)\n"
|
"# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)\n"
|
||||||
"#endif\n";
|
"#endif\n";
|
||||||
emitObjCConditional([&] {
|
emitObjCConditional(out, [&] {
|
||||||
out << "#if !defined(IBSegueAction)\n"
|
out << "#if !defined(IBSegueAction)\n"
|
||||||
"# define IBSegueAction\n"
|
"# define IBSegueAction\n"
|
||||||
"#endif\n";
|
"#endif\n";
|
||||||
@@ -295,7 +301,8 @@ static void writePrologue(raw_ostream &out, ASTContext &ctx,
|
|||||||
};
|
};
|
||||||
emitMacro("SWIFT_CALL", "__attribute__((swiftcall))");
|
emitMacro("SWIFT_CALL", "__attribute__((swiftcall))");
|
||||||
// SWIFT_NOEXCEPT applies 'noexcept' in C++ mode only.
|
// SWIFT_NOEXCEPT applies 'noexcept' in C++ mode only.
|
||||||
emitCxxConditional([&] { emitMacro("SWIFT_NOEXCEPT", "noexcept"); },
|
emitCxxConditional(
|
||||||
|
out, [&] { emitMacro("SWIFT_NOEXCEPT", "noexcept"); },
|
||||||
[&] { emitMacro("SWIFT_NOEXCEPT"); });
|
[&] { emitMacro("SWIFT_NOEXCEPT"); });
|
||||||
static_assert(SWIFT_MAX_IMPORTED_SIMD_ELEMENTS == 4,
|
static_assert(SWIFT_MAX_IMPORTED_SIMD_ELEMENTS == 4,
|
||||||
"need to add SIMD typedefs here if max elements is increased");
|
"need to add SIMD typedefs here if max elements is increased");
|
||||||
@@ -442,33 +449,33 @@ static std::string computeMacroGuard(const ModuleDecl *M) {
|
|||||||
return (llvm::Twine(M->getNameStr().upper()) + "_SWIFT_H").str();
|
return (llvm::Twine(M->getNameStr().upper()) + "_SWIFT_H").str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool swift::printAsObjC(raw_ostream &os, ModuleDecl *M,
|
static std::string getModuleContentsCxxString(ModuleDecl &M) {
|
||||||
|
SmallPtrSet<ImportModuleTy, 8> imports;
|
||||||
|
std::string moduleContentsBuf;
|
||||||
|
llvm::raw_string_ostream moduleContents{moduleContentsBuf};
|
||||||
|
printModuleContentsAsCxx(moduleContents, imports, M);
|
||||||
|
return moduleContents.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool swift::printAsClangHeader(raw_ostream &os, ModuleDecl *M,
|
||||||
StringRef bridgingHeader) {
|
StringRef bridgingHeader) {
|
||||||
llvm::PrettyStackTraceString trace("While generating Objective-C header");
|
llvm::PrettyStackTraceString trace("While generating Clang header");
|
||||||
|
|
||||||
SmallPtrSet<ImportModuleTy, 8> imports;
|
SmallPtrSet<ImportModuleTy, 8> imports;
|
||||||
std::string moduleContentsBuf;
|
std::string objcModuleContentsBuf;
|
||||||
llvm::raw_string_ostream moduleContents{moduleContentsBuf};
|
llvm::raw_string_ostream objcModuleContents{objcModuleContentsBuf};
|
||||||
printModuleContentsAsObjC(moduleContents, imports, *M);
|
printModuleContentsAsObjC(objcModuleContents, imports, *M);
|
||||||
writePrologue(os, M->getASTContext(), computeMacroGuard(M));
|
writePrologue(os, M->getASTContext(), computeMacroGuard(M));
|
||||||
writeImports(os, imports, *M, bridgingHeader);
|
emitObjCConditional(os,
|
||||||
|
[&] { writeImports(os, imports, *M, bridgingHeader); });
|
||||||
writePostImportPrologue(os, *M);
|
writePostImportPrologue(os, *M);
|
||||||
os << moduleContents.str();
|
emitObjCConditional(os, [&] { os << objcModuleContents.str(); });
|
||||||
writeEpilogue(os);
|
emitCxxConditional(os, [&] {
|
||||||
|
// FIXME: Expose Swift with @expose by default.
|
||||||
return false;
|
if (M->getASTContext().LangOpts.EnableCXXInterop) {
|
||||||
}
|
os << getModuleContentsCxxString(*M);
|
||||||
|
}
|
||||||
bool swift::printAsCXX(raw_ostream &os, ModuleDecl *M) {
|
});
|
||||||
llvm::PrettyStackTraceString trace("While generating C++ header");
|
|
||||||
|
|
||||||
SmallPtrSet<ImportModuleTy, 8> imports;
|
|
||||||
std::string moduleContentsBuf;
|
|
||||||
llvm::raw_string_ostream moduleContents{moduleContentsBuf};
|
|
||||||
printModuleContentsAsCxx(moduleContents, imports, *M);
|
|
||||||
writePrologue(os, M->getASTContext(), computeMacroGuard(M));
|
|
||||||
writePostImportPrologue(os, *M);
|
|
||||||
os << moduleContents.str();
|
|
||||||
writeEpilogue(os);
|
writeEpilogue(os);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
|
|
||||||
// RUN: %target-build-swift -typecheck -driver-print-actions -import-objc-header %S/Inputs/bridging-header.h %s 2>&1 | %FileCheck %s -check-prefix=YESPCHACT
|
// RUN: %target-build-swift -typecheck -driver-print-actions -import-objc-header %S/Inputs/bridging-header.h %s 2>&1 | %FileCheck %s -check-prefix=YESPCHACT
|
||||||
// YESPCHACT: 0: input, "{{.*}}Inputs/bridging-header.h", objc-header
|
// YESPCHACT: 0: input, "{{.*}}Inputs/bridging-header.h", clang-header
|
||||||
// YESPCHACT: 1: generate-pch, {0}, pch
|
// YESPCHACT: 1: generate-pch, {0}, pch
|
||||||
// YESPCHACT: 2: input, "{{.*}}bridging-pch.swift", swift
|
// YESPCHACT: 2: input, "{{.*}}bridging-pch.swift", swift
|
||||||
// YESPCHACT: 3: compile, {2, 1}, none
|
// YESPCHACT: 3: compile, {2, 1}, none
|
||||||
@@ -30,13 +30,13 @@
|
|||||||
// Test persistent PCH
|
// Test persistent PCH
|
||||||
|
|
||||||
// RUN: %target-build-swift -typecheck -driver-print-actions -import-objc-header %S/Inputs/bridging-header.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck %s -check-prefix=PERSISTENT-YESPCHACT
|
// RUN: %target-build-swift -typecheck -driver-print-actions -import-objc-header %S/Inputs/bridging-header.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck %s -check-prefix=PERSISTENT-YESPCHACT
|
||||||
// PERSISTENT-YESPCHACT: 0: input, "{{.*}}Inputs/bridging-header.h", objc-header
|
// PERSISTENT-YESPCHACT: 0: input, "{{.*}}Inputs/bridging-header.h", clang-header
|
||||||
// PERSISTENT-YESPCHACT: 1: generate-pch, {0}, none
|
// PERSISTENT-YESPCHACT: 1: generate-pch, {0}, none
|
||||||
// PERSISTENT-YESPCHACT: 2: input, "{{.*}}bridging-pch.swift", swift
|
// PERSISTENT-YESPCHACT: 2: input, "{{.*}}bridging-pch.swift", swift
|
||||||
// PERSISTENT-YESPCHACT: 3: compile, {2, 1}, none
|
// PERSISTENT-YESPCHACT: 3: compile, {2, 1}, none
|
||||||
|
|
||||||
// RUN: %target-build-swift -c -driver-print-actions -embed-bitcode -import-objc-header %S/Inputs/bridging-header.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck %s -check-prefix=PERSISTENT-YESPCHACTBC
|
// RUN: %target-build-swift -c -driver-print-actions -embed-bitcode -import-objc-header %S/Inputs/bridging-header.h -pch-output-dir %t/pch %s 2>&1 | %FileCheck %s -check-prefix=PERSISTENT-YESPCHACTBC
|
||||||
// PERSISTENT-YESPCHACTBC: 0: input, "{{.*}}Inputs/bridging-header.h", objc-header
|
// PERSISTENT-YESPCHACTBC: 0: input, "{{.*}}Inputs/bridging-header.h", clang-header
|
||||||
// PERSISTENT-YESPCHACTBC: 1: generate-pch, {0}, none
|
// PERSISTENT-YESPCHACTBC: 1: generate-pch, {0}, none
|
||||||
// PERSISTENT-YESPCHACTBC: 2: input, "{{.*}}bridging-pch.swift", swift
|
// PERSISTENT-YESPCHACTBC: 2: input, "{{.*}}bridging-pch.swift", swift
|
||||||
// PERSISTENT-YESPCHACTBC: 3: compile, {2, 1}, llvm-bc
|
// PERSISTENT-YESPCHACTBC: 3: compile, {2, 1}, llvm-bc
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output.swift.tmp.swiftsourceinfo"
|
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output.swift.tmp.swiftsourceinfo"
|
||||||
// CHECK-NEXT: },
|
// CHECK-NEXT: },
|
||||||
// CHECK-NEXT: {
|
// CHECK-NEXT: {
|
||||||
// CHECK-NEXT: "type": "objc-header",
|
// CHECK-NEXT: "type": "clang-header",
|
||||||
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output.swift.tmp.h"
|
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output.swift.tmp.h"
|
||||||
// CHECK-NEXT: }
|
// CHECK-NEXT: }
|
||||||
// CHECK-NEXT: ],
|
// CHECK-NEXT: ],
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_unicode.swift.tmp.swiftsourceinfo"
|
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_unicode.swift.tmp.swiftsourceinfo"
|
||||||
// CHECK-NEXT: },
|
// CHECK-NEXT: },
|
||||||
// CHECK-NEXT: {
|
// CHECK-NEXT: {
|
||||||
// CHECK-NEXT: "type": "objc-header",
|
// CHECK-NEXT: "type": "clang-header",
|
||||||
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_unicode.swift.tmp.h"
|
// CHECK-NEXT: "path": "{{.*[\\/]}}parseable_output_unicode.swift.tmp.h"
|
||||||
// CHECK-NEXT: }
|
// CHECK-NEXT: }
|
||||||
// CHECK-NEXT: ],
|
// CHECK-NEXT: ],
|
||||||
|
|||||||
@@ -18,18 +18,11 @@
|
|||||||
// RESOLVE_IMPORTS_NO_REFERENCE_DEPS: error: this mode does not support emitting reference dependency files{{$}}
|
// RESOLVE_IMPORTS_NO_REFERENCE_DEPS: error: this mode does not support emitting reference dependency files{{$}}
|
||||||
|
|
||||||
// RUN: not %target-swift-frontend -parse -emit-objc-header %s 2>&1 | %FileCheck -check-prefix=PARSE_NO_OBJC_HEADER %s
|
// RUN: not %target-swift-frontend -parse -emit-objc-header %s 2>&1 | %FileCheck -check-prefix=PARSE_NO_OBJC_HEADER %s
|
||||||
// PARSE_NO_OBJC_HEADER: error: this mode does not support emitting Objective-C headers{{$}}
|
// PARSE_NO_OBJC_HEADER: error: this mode does not support emitting Objective-C or C++ headers{{$}}
|
||||||
// RUN: not %target-swift-frontend -dump-ast -emit-objc-header %s 2>&1 | %FileCheck -check-prefix=DUMP_NO_OBJC_HEADER %s
|
// RUN: not %target-swift-frontend -dump-ast -emit-objc-header %s 2>&1 | %FileCheck -check-prefix=DUMP_NO_OBJC_HEADER %s
|
||||||
// DUMP_NO_OBJC_HEADER: error: this mode does not support emitting Objective-C headers{{$}}
|
// DUMP_NO_OBJC_HEADER: error: this mode does not support emitting Objective-C or C++ headers{{$}}
|
||||||
// RUN: not %target-swift-frontend -resolve-imports -emit-objc-header %s 2>&1 | %FileCheck -check-prefix=RESOLVE_IMPORTS_NO_OBJC_HEADER %s
|
// RUN: not %target-swift-frontend -resolve-imports -emit-objc-header %s 2>&1 | %FileCheck -check-prefix=RESOLVE_IMPORTS_NO_OBJC_HEADER %s
|
||||||
// RESOLVE_IMPORTS_NO_OBJC_HEADER: error: this mode does not support emitting Objective-C headers{{$}}
|
// RESOLVE_IMPORTS_NO_OBJC_HEADER: error: this mode does not support emitting Objective-C or C++ headers{{$}}
|
||||||
|
|
||||||
// RUN: not %target-swift-frontend -parse -emit-cxx-header %s 2>&1 | %FileCheck -check-prefix=PARSE_NO_CXX_HEADER %s
|
|
||||||
// PARSE_NO_CXX_HEADER: error: this mode does not support emitting C++ headers{{$}}
|
|
||||||
// RUN: not %target-swift-frontend -dump-ast -emit-cxx-header %s 2>&1 | %FileCheck -check-prefix=DUMP_NO_CXX_HEADER %s
|
|
||||||
// DUMP_NO_CXX_HEADER: error: this mode does not support emitting C++ headers{{$}}
|
|
||||||
// RUN: not %target-swift-frontend -resolve-imports -emit-cxx-header %s 2>&1 | %FileCheck -check-prefix=RESOLVE_IMPORTS_NO_CXX_HEADER %s
|
|
||||||
// RESOLVE_IMPORTS_NO_CXX_HEADER: error: this mode does not support emitting C++ headers{{$}}
|
|
||||||
|
|
||||||
// RUN: not %target-swift-frontend -parse -emit-module-interface-path %t %s 2>&1 | %FileCheck -check-prefix=PARSE_NO_INTERFACE %s
|
// RUN: not %target-swift-frontend -parse -emit-module-interface-path %t %s 2>&1 | %FileCheck -check-prefix=PARSE_NO_INTERFACE %s
|
||||||
// PARSE_NO_INTERFACE: error: this mode does not support emitting module interface files{{$}}
|
// PARSE_NO_INTERFACE: error: this mode does not support emitting module interface files{{$}}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
|
|
||||||
// RUN: %target-swift-frontend %S/cdecl.swift -typecheck -module-name CdeclFunctions -emit-cxx-header-path %t/functions.h
|
// RUN: %target-swift-frontend %S/cdecl.swift -typecheck -module-name CdeclFunctions -enable-cxx-interop -emit-clang-header-path %t/functions.h
|
||||||
|
|
||||||
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/cdecl-execution.o
|
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/cdecl-execution.o
|
||||||
// RUN: %target-interop-build-swift %S/cdecl.swift -o %t/cdecl-execution -Xlinker %t/cdecl-execution.o -module-name Functions -Xfrontend -entry-point-function-name -Xfrontend swiftMain
|
// RUN: %target-interop-build-swift %S/cdecl.swift -o %t/cdecl-execution -Xlinker %t/cdecl-execution.o -module-name Functions -Xfrontend -entry-point-function-name -Xfrontend swiftMain
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
// RUN: %target-swift-frontend %s -typecheck -module-name CdeclFunctions -emit-cxx-header-path %t/cdecl.h
|
// RUN: %target-swift-frontend %s -typecheck -module-name CdeclFunctions -enable-cxx-interop -emit-clang-header-path %t/cdecl.h
|
||||||
// RUN: %FileCheck %s < %t/cdecl.h
|
// RUN: %FileCheck %s < %t/cdecl.h
|
||||||
|
|
||||||
// RUN: %check-interop-cxx-header-in-clang(%t/cdecl.h)
|
// RUN: %check-interop-cxx-header-in-clang(%t/cdecl.h)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -emit-cxx-header-path %t/functions.h
|
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -enable-cxx-interop -emit-clang-header-path %t/functions.h
|
||||||
// RUN: %FileCheck %s < %t/functions.h
|
// RUN: %FileCheck %s < %t/functions.h
|
||||||
|
|
||||||
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
|
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
|
|
||||||
// RUN: %target-swift-frontend %S/swift-functions.swift -typecheck -module-name Functions -emit-cxx-header-path %t/functions.h
|
// RUN: %target-swift-frontend %S/swift-functions.swift -typecheck -module-name Functions -enable-cxx-interop -emit-clang-header-path %t/functions.h
|
||||||
|
|
||||||
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-functions-execution.o
|
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-functions-execution.o
|
||||||
// RUN: %target-interop-build-swift %S/swift-functions.swift -o %t/swift-functions-execution -Xlinker %t/swift-functions-execution.o -module-name Functions -Xfrontend -entry-point-function-name -Xfrontend swiftMain
|
// RUN: %target-interop-build-swift %S/swift-functions.swift -o %t/swift-functions-execution -Xlinker %t/swift-functions-execution.o -module-name Functions -Xfrontend -entry-point-function-name -Xfrontend swiftMain
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -emit-cxx-header-path %t/functions.h
|
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -enable-cxx-interop -emit-clang-header-path %t/functions.h
|
||||||
// RUN: %FileCheck %s < %t/functions.h
|
// RUN: %FileCheck %s < %t/functions.h
|
||||||
|
|
||||||
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
|
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -module-name Test -emit-cxx-header-path %t/empty.h
|
// RUN: %target-swift-frontend %s -typecheck -module-name Test -enable-cxx-interop -emit-clang-header-path %t/empty.h
|
||||||
// RUN: %FileCheck %s < %t/empty.h
|
// RUN: %FileCheck %s < %t/empty.h
|
||||||
|
|
||||||
// RUN: %check-interop-cxx-header-in-clang(%t/empty.h)
|
// RUN: %check-interop-cxx-header-in-clang(%t/empty.h)
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
// RUN: %empty-directory(%t)
|
// RUN: %empty-directory(%t)
|
||||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -emit-cxx-header-path %t/empty.h
|
// RUN: %target-swift-frontend %s -typecheck -enable-cxx-interop -emit-clang-header-path %t/empty.h
|
||||||
// RUN: %FileCheck %s < %t/empty.h
|
// RUN: %FileCheck %s < %t/empty.h
|
||||||
|
|
||||||
// RUN: %check-cxx-header-in-clang -std=c++14 %t/empty.h
|
|
||||||
// RUN: %check-cxx-header-in-clang -std=c++17 %t/empty.h
|
|
||||||
|
|
||||||
// CHECK-NOT: @import Swift;
|
|
||||||
// CHECK-NOT: IBSegueAction
|
|
||||||
|
|
||||||
// CHECK-LABEL: #ifndef EMPTY_SWIFT_H
|
// CHECK-LABEL: #ifndef EMPTY_SWIFT_H
|
||||||
// CHECK-NEXT: #define EMPTY_SWIFT_H
|
// CHECK-NEXT: #define EMPTY_SWIFT_H
|
||||||
|
|
||||||
@@ -63,7 +57,19 @@
|
|||||||
// CHECK: # define SWIFT_EXTENSION(M)
|
// CHECK: # define SWIFT_EXTENSION(M)
|
||||||
// CHECK: # define OBJC_DESIGNATED_INITIALIZER
|
// CHECK: # define OBJC_DESIGNATED_INITIALIZER
|
||||||
|
|
||||||
// CHECK-LABEL: namespace empty {
|
// CHECK-LABEL: #if defined(__OBJC__)
|
||||||
|
// CHECK-NEXT: #if !defined(IBSegueAction)
|
||||||
|
// CHECK-NEXT: # define IBSegueAction
|
||||||
|
// CHECK-NEXT: #endif
|
||||||
|
|
||||||
|
// CHECK-LABEL: #if defined(__OBJC__)
|
||||||
|
// CHECK-NEXT: #if __has_feature(modules)
|
||||||
|
|
||||||
|
// CHECK-LABEL: #if defined(__OBJC__)
|
||||||
|
// CHECK-NEXT: #endif
|
||||||
|
// CHECK-NEXT: #if defined(__cplusplus)
|
||||||
|
// CHECK-NEXT: namespace empty {
|
||||||
// CHECK: } // namespace empty
|
// CHECK: } // namespace empty
|
||||||
|
// CHECK: #endif
|
||||||
|
|
||||||
// CHECK-NOT: @
|
// CHECK-NOT: @
|
||||||
|
|||||||
@@ -424,6 +424,9 @@ SWIFT_CLASS("_TtC8comments13UnorderedList")
|
|||||||
- (void)f0;
|
- (void)f0;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#endif
|
||||||
#if __has_attribute(external_source_symbol)
|
#if __has_attribute(external_source_symbol)
|
||||||
# pragma clang attribute pop
|
# pragma clang attribute pop
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user