Skip to content

NFC opaque type cleanups #24463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/IRGen/GenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,18 +1160,19 @@ void IRGenerator::addLazyFunction(SILFunction *f) {
}

bool IRGenerator::hasLazyMetadata(TypeDecl *type) {
assert(isa<NominalTypeDecl>(type) ||
isa<OpaqueTypeDecl>(type));
auto found = HasLazyMetadata.find(type);
if (found != HasLazyMetadata.end())
return found->second;

auto canBeLazy = [&]() -> bool {
if (isa<ClangModuleUnit>(type->getInnermostDeclContext()
->getModuleScopeContext())) {
auto *dc = type->getDeclContext();
if (isa<ClangModuleUnit>(dc->getModuleScopeContext())) {
if (auto nominal = dyn_cast<NominalTypeDecl>(type)) {
return requiresForeignTypeMetadata(nominal);
}
} else if (type->getInnermostDeclContext()->getParentModule()
== SIL.getSwiftModule()) {
} else if (dc->getParentModule() == SIL.getSwiftModule()) {
// When compiling with -Onone keep all metadata for the debugger. Even if
// it is not used by the program itself.
if (!Opts.shouldOptimize())
Expand Down
1 change: 0 additions & 1 deletion lib/IRGen/IRGenModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ class IRGenerator {
/// queued up.
llvm::SmallPtrSet<NominalTypeDecl *, 4> LazilyEmittedFieldMetadata;
struct LazyOpaqueInfo {
bool IsLazy = false;
bool IsDescriptorUsed = false;
bool IsDescriptorEmitted = false;
};
Expand Down
6 changes: 1 addition & 5 deletions lib/Sema/TypeCheckAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,7 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
UNINTERESTING(Var) // Handled at the PatternBinding level.
UNINTERESTING(Destructor) // Always correct.
UNINTERESTING(Accessor) // Handled by the Var or Subscript.
UNINTERESTING(OpaqueType) // Handled by the Var or Subscript.

/// If \p PBD declared stored instance properties in a fixed-contents struct,
/// return said struct.
Expand Down Expand Up @@ -1193,11 +1194,6 @@ class UsableFromInlineChecker : public AccessControlCheckerBase,
});
}

void visitOpaqueTypeDecl(OpaqueTypeDecl *OTD) {
// TODO(opaque): The constraint class/protocols on the opaque interface, as
// well as the naming decl for the opaque type, need to be accessible.
}

void visitAssociatedTypeDecl(AssociatedTypeDecl *assocType) {
// This must stay in sync with diag::associated_type_not_usable_from_inline.
enum {
Expand Down