Skip to content

Commit 5662c4b

Browse files
author
David Ungar
committed
Remove redundant getMembers
Also make LazyMemberLoader abstract Add "final" to (Class|Protocol|Enum|Struct)Decl classes
1 parent fc8cbc4 commit 5662c4b

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

include/swift/AST/Decl.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,8 +1722,6 @@ class ExtensionDecl final : public Decl, public GenericContext,
17221722

17231723
void setConformanceLoader(LazyMemberLoader *resolver, uint64_t contextData);
17241724

1725-
DeclRange getMembers() const;
1726-
17271725
/// Determine whether this is a constrained extension, which adds additional
17281726
/// requirements beyond those of the nominal type.
17291727
bool isConstrainedExtension() const;
@@ -2775,7 +2773,6 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
27752773
public:
27762774
using GenericTypeDecl::getASTContext;
27772775

2778-
DeclRange getMembers() const;
27792776
SourceRange getBraces() const { return Braces; }
27802777

27812778
void setBraces(SourceRange braces) { Braces = braces; }
@@ -2967,7 +2964,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
29672964
///
29682965
/// The type of the decl itself is a MetatypeType; use getDeclaredType()
29692966
/// to get the declared type ("Bool" or "Optional" in the above example).
2970-
class EnumDecl : public NominalTypeDecl {
2967+
class EnumDecl final : public NominalTypeDecl {
29712968
SourceLoc EnumLoc;
29722969

29732970
struct {
@@ -3123,7 +3120,7 @@ class EnumDecl : public NominalTypeDecl {
31233120
///
31243121
/// The type of the decl itself is a MetatypeType; use getDeclaredType()
31253122
/// to get the declared type ("Complex" in the above example).
3126-
class StructDecl : public NominalTypeDecl {
3123+
class StructDecl final : public NominalTypeDecl {
31273124
SourceLoc StructLoc;
31283125

31293126
public:
@@ -3193,7 +3190,7 @@ enum class ObjCClassKind : uint8_t {
31933190
///
31943191
/// The type of the decl itself is a MetatypeType; use getDeclaredType()
31953192
/// to get the declared type ("Complex" in the above example).
3196-
class ClassDecl : public NominalTypeDecl {
3193+
class ClassDecl final : public NominalTypeDecl {
31973194
class ObjCMethodLookupTable;
31983195

31993196
SourceLoc ClassLoc;
@@ -3488,7 +3485,7 @@ struct SelfReferenceKind {
34883485
/// protocol Drawable {
34893486
/// func draw()
34903487
/// }
3491-
class ProtocolDecl : public NominalTypeDecl {
3488+
class ProtocolDecl final : public NominalTypeDecl {
34923489
SourceLoc ProtocolLoc;
34933490

34943491
/// The location of the 'class' keyword for class-bound protocols.

include/swift/AST/LazyResolver.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,37 +211,27 @@ class alignas(void*) LazyMemberLoader {
211211
///
212212
/// The implementation should add the members to D.
213213
virtual void
214-
loadAllMembers(Decl *D, uint64_t contextData) {
215-
llvm_unreachable("unimplemented");
216-
}
214+
loadAllMembers(Decl *D, uint64_t contextData) = 0;
217215

218216
/// Populates the given vector with all conformances for \p D.
219217
///
220218
/// The implementation should \em not call setConformances on \p D.
221219
virtual void
222220
loadAllConformances(const Decl *D, uint64_t contextData,
223-
SmallVectorImpl<ProtocolConformance *> &Conformances) {
224-
llvm_unreachable("unimplemented");
225-
}
221+
SmallVectorImpl<ProtocolConformance *> &Conformances) = 0;
226222

227223
/// Populates the given vector with all conformances for \p D.
228224
virtual void
229225
finishNormalConformance(NormalProtocolConformance *conformance,
230-
uint64_t contextData) {
231-
llvm_unreachable("unimplemented");
232-
}
226+
uint64_t contextData) = 0;
233227

234228
/// Returns the default definition type for \p ATD.
235229
virtual TypeLoc loadAssociatedTypeDefault(const AssociatedTypeDecl *ATD,
236-
uint64_t contextData) {
237-
llvm_unreachable("unimplemented");
238-
}
230+
uint64_t contextData) = 0;
239231

240232
/// Returns the generic environment.
241233
virtual GenericEnvironment *loadGenericEnvironment(const DeclContext *decl,
242-
uint64_t contextData) {
243-
llvm_unreachable("unimplemented");
244-
}
234+
uint64_t contextData) = 0;
245235
};
246236

247237
}

lib/AST/Decl.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,6 @@ ImportDecl::findBestImportKind(ArrayRef<ValueDecl *> Decls) {
807807
return FirstKind;
808808
}
809809

810-
DeclRange NominalTypeDecl::getMembers() const {
811-
loadAllMembers();
812-
return IterableDeclContext::getMembers();
813-
}
814-
815810
void NominalTypeDecl::setConformanceLoader(LazyMemberLoader *lazyLoader,
816811
uint64_t contextData) {
817812
assert(!NominalTypeDeclBits.HasLazyConformances &&
@@ -871,11 +866,6 @@ ExtensionDecl *ExtensionDecl::create(ASTContext &ctx, SourceLoc extensionLoc,
871866
return result;
872867
}
873868

874-
DeclRange ExtensionDecl::getMembers() const {
875-
loadAllMembers();
876-
return IterableDeclContext::getMembers();
877-
}
878-
879869
void ExtensionDecl::setConformanceLoader(LazyMemberLoader *lazyLoader,
880870
uint64_t contextData) {
881871
assert(!ExtensionDeclBits.HasLazyConformances &&

lib/ClangImporter/ImporterImpl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,18 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
11261126

11271127
void finishNormalConformance(NormalProtocolConformance *conformance,
11281128
uint64_t unused) override;
1129+
1130+
/// Returns the default definition type for \p ATD.
1131+
TypeLoc loadAssociatedTypeDefault(const AssociatedTypeDecl *ATD,
1132+
uint64_t contextData) override {
1133+
llvm_unreachable("unimplemented for ClangImporter");
1134+
}
1135+
1136+
/// Returns the generic environment.
1137+
virtual GenericEnvironment *loadGenericEnvironment(const DeclContext *decl,
1138+
uint64_t contextData) override {
1139+
llvm_unreachable("unimplemented for ClangImporter");
1140+
}
11291141

11301142
template <typename DeclTy, typename ...Targs>
11311143
DeclTy *createDeclWithClangNode(ClangNode ClangN, Accessibility access,

0 commit comments

Comments
 (0)