IRGen: Exclude unavailable enum cases from runtime layout calculations.

When `-unavailable-decl-optimization=complete` is specified, exclude
unavailable enum cases from the runtime layout of enums with payloads. Without
this, the type metadata for unavailable types may be referenced by enum cases
with unavailable payloads and cause linker failures.

Resolves rdar://107483852
This commit is contained in:
Allan Shortlidge
2023-04-02 22:17:18 -07:00
parent 570c364cc4
commit ce97377218
9 changed files with 89 additions and 11 deletions

View File

@@ -956,7 +956,7 @@ bool Lowering::usesObjCAllocator(ClassDecl *theClass) {
return theClass->getObjectModel() == ReferenceCounting::ObjC;
}
bool Lowering::shouldSkipLowering(Decl *D) {
bool Lowering::shouldSkipLowering(const Decl *D) {
if (D->getASTContext().LangOpts.UnavailableDeclOptimizationMode !=
UnavailableDeclOptimization::Complete)
return false;
@@ -966,7 +966,7 @@ bool Lowering::shouldSkipLowering(Decl *D) {
return D->getSemanticUnavailableAttr() != None;
}
bool Lowering::shouldLowerToUnavailableCodeStub(Decl *D) {
bool Lowering::shouldLowerToUnavailableCodeStub(const Decl *D) {
if (D->getASTContext().LangOpts.UnavailableDeclOptimizationMode !=
UnavailableDeclOptimization::Stub)
return false;