mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Completely remove NominalTypeDecl::LookupDirectFlags::IgnoreNewExtensions
This commit is contained in:
@@ -3275,7 +3275,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
|
||||
llvm::PointerIntPair<MemberLookupTable *, 1, bool> LookupTable;
|
||||
|
||||
/// Prepare the lookup table to make it ready for lookups.
|
||||
void prepareLookupTable(bool ignoreNewExtensions);
|
||||
void prepareLookupTable();
|
||||
|
||||
/// True if the entries in \c LookupTable are complete--that is, if a
|
||||
/// name is present, it contains all members with that name.
|
||||
@@ -3383,12 +3383,9 @@ public:
|
||||
|
||||
/// Special-behaviour flags passed to lookupDirect()
|
||||
enum class LookupDirectFlags {
|
||||
/// Whether to avoid loading any new extension.
|
||||
/// Used by the module loader to break recursion.
|
||||
IgnoreNewExtensions = 1 << 0,
|
||||
/// Whether to include @_implements members.
|
||||
/// Used by conformance-checking to find special @_implements members.
|
||||
IncludeAttrImplements = 1 << 1,
|
||||
IncludeAttrImplements = 1 << 0,
|
||||
};
|
||||
|
||||
/// Find all of the declarations with the given name within this nominal type
|
||||
|
||||
@@ -3906,10 +3906,7 @@ bool ClassDecl::hasMissingDesignatedInitializers() const {
|
||||
if (!Bits.ClassDecl.ComputedHasMissingDesignatedInitializers) {
|
||||
auto *mutableThis = const_cast<ClassDecl *>(this);
|
||||
mutableThis->Bits.ClassDecl.ComputedHasMissingDesignatedInitializers = 1;
|
||||
auto flags = OptionSet<LookupDirectFlags>();
|
||||
flags |= LookupDirectFlags::IgnoreNewExtensions;
|
||||
(void)mutableThis->lookupDirect(DeclBaseName::createConstructor(),
|
||||
flags);
|
||||
(void)mutableThis->lookupDirect(DeclBaseName::createConstructor());
|
||||
}
|
||||
|
||||
return Bits.ClassDecl.HasMissingDesignatedInitializers;
|
||||
|
||||
@@ -1008,9 +1008,6 @@ void ExtensionDecl::addedMember(Decl *member) {
|
||||
// If the IDC list is later populated and/or an extension is added _after_
|
||||
// MemberLookupTable is constructed (and possibly has entries in it),
|
||||
// MemberLookupTable is purged and reconstructed from IDC's list.
|
||||
//
|
||||
// In all lookup routines, the 'ignoreNewExtensions' flag means that
|
||||
// lookup should only use the set of extensions already observed.
|
||||
|
||||
static bool
|
||||
populateLookupTableEntryFromLazyIDCLoader(ASTContext &ctx,
|
||||
@@ -1058,19 +1055,16 @@ static void
|
||||
populateLookupTableEntryFromExtensions(ASTContext &ctx,
|
||||
MemberLookupTable &table,
|
||||
NominalTypeDecl *nominal,
|
||||
DeclName name,
|
||||
bool ignoreNewExtensions) {
|
||||
if (!ignoreNewExtensions) {
|
||||
for (auto e : nominal->getExtensions()) {
|
||||
if (e->wasDeserialized() || e->hasClangNode()) {
|
||||
assert(!e->hasUnparsedMembers());
|
||||
if (populateLookupTableEntryFromLazyIDCLoader(ctx, table,
|
||||
name, e)) {
|
||||
populateLookupTableEntryFromCurrentMembers(ctx, table, name, e);
|
||||
}
|
||||
} else {
|
||||
DeclName name) {
|
||||
for (auto e : nominal->getExtensions()) {
|
||||
if (e->wasDeserialized() || e->hasClangNode()) {
|
||||
assert(!e->hasUnparsedMembers());
|
||||
if (populateLookupTableEntryFromLazyIDCLoader(ctx, table,
|
||||
name, e)) {
|
||||
populateLookupTableEntryFromCurrentMembers(ctx, table, name, e);
|
||||
}
|
||||
} else {
|
||||
populateLookupTableEntryFromCurrentMembers(ctx, table, name, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1083,7 +1077,7 @@ void NominalTypeDecl::setLookupTablePopulated(bool value) {
|
||||
LookupTable.setInt(value);
|
||||
}
|
||||
|
||||
void NominalTypeDecl::prepareLookupTable(bool ignoreNewExtensions) {
|
||||
void NominalTypeDecl::prepareLookupTable() {
|
||||
// If we haven't allocated the lookup table yet, do so now.
|
||||
if (!LookupTable.getPointer()) {
|
||||
auto &ctx = getASTContext();
|
||||
@@ -1109,8 +1103,7 @@ void NominalTypeDecl::prepareLookupTable(bool ignoreNewExtensions) {
|
||||
for (auto baseName : baseNamesPresent) {
|
||||
populateLookupTableEntryFromExtensions(getASTContext(),
|
||||
*LookupTable.getPointer(),
|
||||
this, baseName,
|
||||
ignoreNewExtensions);
|
||||
this, baseName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1121,9 +1114,7 @@ void NominalTypeDecl::prepareLookupTable(bool ignoreNewExtensions) {
|
||||
setLookupTablePopulated(true);
|
||||
LookupTable.getPointer()->addMembers(getMembers());
|
||||
}
|
||||
if (!ignoreNewExtensions) {
|
||||
LookupTable.getPointer()->updateLookupTable(this);
|
||||
}
|
||||
LookupTable.getPointer()->updateLookupTable(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,9 +1152,6 @@ TinyPtrVector<ValueDecl *> NominalTypeDecl::lookupDirect(
|
||||
bool useNamedLazyMemberLoading = (ctx.LangOpts.NamedLazyMemberLoading &&
|
||||
hasLazyMembers());
|
||||
|
||||
bool ignoreNewExtensions =
|
||||
flags.contains(LookupDirectFlags::IgnoreNewExtensions);
|
||||
|
||||
bool includeAttrImplements =
|
||||
flags.contains(LookupDirectFlags::IncludeAttrImplements);
|
||||
|
||||
@@ -1175,7 +1163,7 @@ TinyPtrVector<ValueDecl *> NominalTypeDecl::lookupDirect(
|
||||
useNamedLazyMemberLoading = false;
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << getNameStr() << ".lookupDirect("
|
||||
<< name << ", " << ignoreNewExtensions << ")"
|
||||
<< name << ")"
|
||||
<< ", isLookupTablePopulated()=" << isLookupTablePopulated()
|
||||
<< ", hasLazyMembers()=" << hasLazyMembers()
|
||||
<< ", useNamedLazyMemberLoading=" << useNamedLazyMemberLoading
|
||||
@@ -1211,15 +1199,13 @@ TinyPtrVector<ValueDecl *> NominalTypeDecl::lookupDirect(
|
||||
|
||||
// Make sure we have the complete list of members (in this nominal and in
|
||||
// all extensions).
|
||||
if (!ignoreNewExtensions) {
|
||||
for (auto E : getExtensions())
|
||||
(void)E->getMembers();
|
||||
}
|
||||
for (auto E : getExtensions())
|
||||
(void)E->getMembers();
|
||||
}
|
||||
|
||||
// Next, in all cases, prepare the lookup table for use, possibly
|
||||
// repopulating it from the IDC if the IDC member list has just grown.
|
||||
prepareLookupTable(ignoreNewExtensions);
|
||||
prepareLookupTable();
|
||||
|
||||
// Look for a declaration with this name.
|
||||
auto known = LookupTable.getPointer()->find(name);
|
||||
@@ -1243,8 +1229,7 @@ TinyPtrVector<ValueDecl *> NominalTypeDecl::lookupDirect(
|
||||
name, this)) {
|
||||
useNamedLazyMemberLoading = false;
|
||||
} else {
|
||||
populateLookupTableEntryFromExtensions(ctx, Table, this, name,
|
||||
ignoreNewExtensions);
|
||||
populateLookupTableEntryFromExtensions(ctx, Table, this, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -782,9 +782,8 @@ static VarDecl *findAnonymousInnerFieldDecl(VarDecl *importedFieldDecl,
|
||||
auto anonymousFieldTypeDecl
|
||||
= anonymousFieldType->getStructOrBoundGenericStruct();
|
||||
|
||||
auto lookupFlags = NominalTypeDecl::LookupDirectFlags::IgnoreNewExtensions;
|
||||
for (auto decl : anonymousFieldTypeDecl->lookupDirect(
|
||||
importedFieldDecl->getName(), lookupFlags)) {
|
||||
importedFieldDecl->getName())) {
|
||||
if (isa<VarDecl>(decl)) {
|
||||
return cast<VarDecl>(decl);
|
||||
}
|
||||
@@ -8306,8 +8305,7 @@ synthesizeConstantGetterBody(AbstractFunctionDecl *afd, void *voidContext) {
|
||||
DeclName initName = DeclName(ctx, DeclBaseName::createConstructor(),
|
||||
{ ctx.Id_rawValue });
|
||||
auto nominal = type->getAnyNominal();
|
||||
auto lookupFlags = NominalTypeDecl::LookupDirectFlags::IgnoreNewExtensions;
|
||||
for (auto found : nominal->lookupDirect(initName, lookupFlags)) {
|
||||
for (auto found : nominal->lookupDirect(initName)) {
|
||||
init = dyn_cast<ConstructorDecl>(found);
|
||||
if (init && init->getDeclContext() == nominal)
|
||||
break;
|
||||
|
||||
@@ -4855,10 +4855,11 @@ void TypeChecker::checkConformancesInContext(DeclContext *dc,
|
||||
continue;
|
||||
|
||||
bool valueIsType = isa<TypeDecl>(value);
|
||||
auto flags = OptionSet<NominalTypeDecl::LookupDirectFlags>();
|
||||
flags |= NominalTypeDecl::LookupDirectFlags::IgnoreNewExtensions;
|
||||
for (auto requirement
|
||||
: diag.Protocol->lookupDirect(value->getFullName(), flags)) {
|
||||
: diag.Protocol->lookupDirect(value->getFullName())) {
|
||||
if (requirement->getDeclContext() != diag.Protocol)
|
||||
continue;
|
||||
|
||||
auto requirementIsType = isa<TypeDecl>(requirement);
|
||||
if (valueIsType != requirementIsType)
|
||||
continue;
|
||||
@@ -5056,9 +5057,7 @@ swift::findWitnessedObjCRequirements(const ValueDecl *witness,
|
||||
if (!proto->isObjC()) continue;
|
||||
|
||||
Optional<ProtocolConformance *> conformance;
|
||||
auto flags = OptionSet<NominalTypeDecl::LookupDirectFlags>();
|
||||
flags |= NominalTypeDecl::LookupDirectFlags::IgnoreNewExtensions;
|
||||
for (auto req : proto->lookupDirect(name, flags)) {
|
||||
for (auto req : proto->lookupDirect(name)) {
|
||||
// Skip anything in a protocol extension.
|
||||
if (req->getDeclContext() != proto) continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user