mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #78623 from cachemeifyoucan/eng/bridging-header-auto-chaining
[BridgingHeader] Auto bridging header chaining
This commit is contained in:
@@ -1425,30 +1425,33 @@ void Serializer::writeInputBlock() {
|
||||
// Make sure the bridging header module is always at the top of the import
|
||||
// list, mimicking how it is processed before any module imports when
|
||||
// compiling source files.
|
||||
if (llvm::is_contained(allLocalImports, bridgingHeaderImport)) {
|
||||
if (llvm::is_contained(allLocalImports, bridgingHeaderImport) &&
|
||||
Options.SerializeBridgingHeader) {
|
||||
off_t importedHeaderSize = 0;
|
||||
time_t importedHeaderModTime = 0;
|
||||
std::string contents;
|
||||
auto importedHeaderPath = Options.ImportedHeader;
|
||||
std::string pchIncludeTree;
|
||||
// We do not want to serialize the explicitly-specified .pch path if one was
|
||||
// provided. Instead we write out the path to the original header source so
|
||||
// that clients can consume it.
|
||||
if (Options.ExplicitModuleBuild &&
|
||||
llvm::sys::path::extension(importedHeaderPath)
|
||||
.ends_with(file_types::getExtension(file_types::TY_PCH))) {
|
||||
auto *pch = clangImporter->getClangInstance()
|
||||
.getASTReader()
|
||||
->getModuleManager()
|
||||
.lookupByFileName(importedHeaderPath);
|
||||
pchIncludeTree = pch->IncludeTreeID;
|
||||
importedHeaderPath = pch->OriginalSourceFileName;
|
||||
}
|
||||
std::string importedHeaderPath;
|
||||
if (!Options.SerializeEmptyBridgingHeader) {
|
||||
importedHeaderPath = Options.ImportedHeader;
|
||||
std::string pchIncludeTree;
|
||||
// We do not want to serialize the explicitly-specified .pch path if one
|
||||
// was provided. Instead we write out the path to the original header
|
||||
// source so that clients can consume it.
|
||||
if (!Options.ImportedPCHPath.empty()) {
|
||||
auto *pch = clangImporter->getClangInstance()
|
||||
.getASTReader()
|
||||
->getModuleManager()
|
||||
.lookupByFileName(Options.ImportedPCHPath);
|
||||
if (importedHeaderPath.empty())
|
||||
importedHeaderPath = pch->OriginalSourceFileName;
|
||||
pchIncludeTree = pch->IncludeTreeID;
|
||||
}
|
||||
|
||||
if (!importedHeaderPath.empty()) {
|
||||
contents = clangImporter->getBridgingHeaderContents(
|
||||
importedHeaderPath, importedHeaderSize, importedHeaderModTime,
|
||||
pchIncludeTree);
|
||||
if (!importedHeaderPath.empty()) {
|
||||
contents = clangImporter->getBridgingHeaderContents(
|
||||
importedHeaderPath, importedHeaderSize, importedHeaderModTime,
|
||||
pchIncludeTree);
|
||||
}
|
||||
}
|
||||
assert(publicImportSet.count(bridgingHeaderImport));
|
||||
ImportedHeader.emit(ScratchRecord,
|
||||
@@ -1542,7 +1545,7 @@ static uint8_t getRawStableDefaultArgumentKind(swift::DefaultArgumentKind kind)
|
||||
llvm_unreachable("Unhandled DefaultArgumentKind in switch.");
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
static uint8_t
|
||||
getRawStableActorIsolationKind(swift::ActorIsolation::Kind kind) {
|
||||
switch (kind) {
|
||||
#define CASE(X) \
|
||||
@@ -3452,14 +3455,14 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
case DeclAttrKind::RawLayout: {
|
||||
auto *attr = cast<RawLayoutAttr>(DA);
|
||||
auto abbrCode = S.DeclTypeAbbrCodes[RawLayoutDeclAttrLayout::Code];
|
||||
|
||||
|
||||
uint32_t rawSize;
|
||||
uint8_t rawAlign;
|
||||
TypeID typeID;
|
||||
TypeID countID;
|
||||
|
||||
|
||||
auto SD = const_cast<StructDecl*>(cast<StructDecl>(D));
|
||||
|
||||
|
||||
if (auto sizeAndAlign = attr->getSizeAndAlignment()) {
|
||||
typeID = 0;
|
||||
countID = 0;
|
||||
@@ -3480,7 +3483,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
|
||||
} else {
|
||||
llvm_unreachable("unhandled raw layout attribute, or trying to serialize unresolved attr!");
|
||||
}
|
||||
|
||||
|
||||
RawLayoutDeclAttrLayout::emitRecord(
|
||||
S.Out, S.ScratchRecord, abbrCode, attr->isImplicit(),
|
||||
typeID, countID, rawSize, rawAlign, attr->shouldMoveAsLikeType());
|
||||
@@ -4102,7 +4105,7 @@ public:
|
||||
|
||||
assert(typeRef >> (NumProtocolConformanceOptions+1) == originalTypeRef);
|
||||
(void)originalTypeRef;
|
||||
|
||||
|
||||
result.push_back(typeRef);
|
||||
}
|
||||
|
||||
@@ -5523,7 +5526,7 @@ public:
|
||||
void visitBuiltinType(BuiltinType *ty) {
|
||||
visitBuiltinTypeImpl(ty);
|
||||
}
|
||||
|
||||
|
||||
void visitBuiltinFixedArrayType(BuiltinFixedArrayType *ty) {
|
||||
using namespace decls_block;
|
||||
unsigned abbrCode = S.DeclTypeAbbrCodes[BuiltinFixedArrayTypeLayout::Code];
|
||||
|
||||
Reference in New Issue
Block a user