Skip to content

Commit c38b9b1

Browse files
authored
Merge pull request #67945 from xedin/remove-runtimeMetadata
[Frontend] NFC: Remove code and tests related to rejected @runtimeMetadata feature
2 parents ab41167 + 4bd60ae commit c38b9b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+10
-2667
lines changed

docs/ABI/Mangling.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ Globals
150150
#endif
151151
global ::= protocol-conformance 'Hc' // protocol conformance runtime record
152152
global ::= global 'HF' // accessible function runtime record
153-
global ::= global 'Ha' // runtime discoverable attribute record
154153

155154
global ::= nominal-type 'Mo' // class metadata immediate member base offset
156155

include/swift/ABI/Metadata.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,48 +4907,6 @@ struct TargetAccessibleFunctionRecord final {
49074907

49084908
using AccessibleFunctionRecord = TargetAccessibleFunctionRecord<InProcess>;
49094909

4910-
/// A single entry in an runtine discoverable attribute record
4911-
/// that relates a type attribute is attached to a generator function.
4912-
template <typename Runtime>
4913-
struct TargetRuntimeDiscoverableAttributeEntry {
4914-
RelativeDirectPointer<const char, /*nullable*/ false> Type;
4915-
RelativeDirectPointer<TargetAccessibleFunctionRecord<Runtime>> Generator;
4916-
};
4917-
4918-
/// A record that relates a runtime discoverable attribute to all of the
4919-
/// types (i.e. a nominal type, method, property etc.) it's attached to.
4920-
template <typename Runtime>
4921-
class RuntimeDiscoverableAttributeRecord
4922-
: private swift::ABI::TrailingObjects<
4923-
RuntimeDiscoverableAttributeRecord<Runtime>,
4924-
TargetRuntimeDiscoverableAttributeEntry<Runtime>> {
4925-
using TrailingObjects = swift::ABI::TrailingObjects<
4926-
RuntimeDiscoverableAttributeRecord<Runtime>,
4927-
ConstTargetMetadataPointer<Runtime, TargetMetadata>>;
4928-
friend TrailingObjects;
4929-
4930-
uint32_t flags;
4931-
4932-
/// The nominal type that describes the attribute.
4933-
TargetRelativeIndirectablePointer<Runtime,
4934-
TargetTypeContextDescriptor<Runtime>,
4935-
/*nullable*/ false>
4936-
Attribute;
4937-
4938-
/// The number of types this attribute is associated with.
4939-
uint32_t numEntries;
4940-
4941-
public:
4942-
uint32_t getFlags() { return flags; }
4943-
4944-
llvm::ArrayRef<TargetRuntimeDiscoverableAttributeEntry<Runtime>>
4945-
getEntries() const {
4946-
return {this->template getTrailingObjects<
4947-
TargetRuntimeDiscoverableAttributeEntry<Runtime>>(),
4948-
numEntries};
4949-
}
4950-
};
4951-
49524910
enum class PackLifetime : uint8_t {
49534911
OnStack = 0,
49544912
OnHeap = 1

include/swift/AST/ASTMangler.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class ASTMangler : public Mangler {
161161
BackDeploymentThunk,
162162
BackDeploymentFallback,
163163
HasSymbolQuery,
164-
RuntimeDiscoverableAttributeRecord,
165164
};
166165

167166
/// lldb overrides the defaulted argument to 'true'.
@@ -363,10 +362,6 @@ class ASTMangler : public Mangler {
363362

364363
std::string mangleHasSymbolQuery(const ValueDecl *decl);
365364

366-
std::string
367-
mangleRuntimeAttributeGeneratorEntity(const ValueDecl *decl, CustomAttr *attr,
368-
SymbolKind SKind = SymbolKind::Default);
369-
370365
std::string mangleMacroExpansion(const FreestandingMacroExpansion *expansion);
371366
std::string mangleAttachedMacroExpansion(
372367
const Decl *decl, CustomAttr *attr, MacroRole role);
@@ -603,9 +598,6 @@ class ASTMangler : public Mangler {
603598

604599
void appendConstrainedExistential(Type base, GenericSignature sig,
605600
const ValueDecl *forDecl);
606-
607-
void appendRuntimeAttributeGeneratorEntity(const ValueDecl *decl,
608-
CustomAttr *attr);
609601
};
610602

611603
} // end namespace Mangle

include/swift/AST/Attr.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,6 @@ DECL_ATTR(_documentation, Documentation,
416416
SIMPLE_DECL_ATTR(_noMetadata, NoMetadata,
417417
OnGenericTypeParam | UserInaccessible | NotSerialized | ABIStableToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
418418
138)
419-
SIMPLE_DECL_ATTR(runtimeMetadata, RuntimeMetadata,
420-
OnStruct | OnClass | OnEnum | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
421-
139)
422419
SIMPLE_DECL_ATTR(_used, Used,
423420
OnAbstractFunction | OnVar | UserInaccessible | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
424421
143)

include/swift/AST/ConstTypeInfo.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,18 @@ struct ConstValueTypePropertyInfo {
233233
swift::VarDecl *VarDecl;
234234
std::shared_ptr<CompileTimeValue> Value;
235235
llvm::Optional<AttrValueVector> PropertyWrappers;
236-
llvm::Optional<AttrValueVector> RuntimeMetadataAttributes;
237236

238237
ConstValueTypePropertyInfo(
239238
swift::VarDecl *VarDecl, std::shared_ptr<CompileTimeValue> Value,
240-
llvm::Optional<AttrValueVector> PropertyWrappers,
241-
llvm::Optional<AttrValueVector> RuntimeMetadataAttributes)
242-
: VarDecl(VarDecl), Value(Value), PropertyWrappers(PropertyWrappers),
243-
RuntimeMetadataAttributes(RuntimeMetadataAttributes) {}
239+
llvm::Optional<AttrValueVector> PropertyWrappers)
240+
: VarDecl(VarDecl), Value(Value), PropertyWrappers(PropertyWrappers)
241+
{}
244242

245243
ConstValueTypePropertyInfo(swift::VarDecl *VarDecl,
246244
std::shared_ptr<CompileTimeValue> Value)
247245
: VarDecl(VarDecl), Value(Value),
248-
PropertyWrappers(llvm::Optional<AttrValueVector>()),
249-
RuntimeMetadataAttributes(llvm::Optional<AttrValueVector>()) {}
246+
PropertyWrappers(llvm::Optional<AttrValueVector>())
247+
{}
250248
};
251249

252250
struct ConstValueTypeInfo {

include/swift/AST/Decl.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,6 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
898898
return Attrs;
899899
}
900900

901-
/// Retrieve runtime discoverable attributes (if any) associated
902-
/// with this declaration.
903-
ArrayRef<CustomAttr *> getRuntimeDiscoverableAttrs() const;
904-
905901
/// Returns the attributes that were directly attached to this declaration
906902
/// as written in source, ie. does not include attributes generated by macro
907903
/// expansions.
@@ -2986,19 +2982,6 @@ class ValueDecl : public Decl {
29862982
/// 'func foo(Int) -> () -> Self?'.
29872983
GenericParameterReferenceInfo findExistentialSelfReferences(
29882984
Type baseTy, bool treatNonResultCovariantSelfAsInvariant) const;
2989-
2990-
/// Retrieve a nominal type declaration backing given runtime discoverable
2991-
/// attribute.
2992-
///
2993-
/// FIXME: This should be a more general facility but its unclear where
2994-
/// to place it for maximum impact.
2995-
NominalTypeDecl *getRuntimeDiscoverableAttrTypeDecl(CustomAttr *attr) const;
2996-
2997-
/// Given a runtime discoverable attribute, return a generator
2998-
/// which could be used to instantiate it for this declaration
2999-
/// together with its result type.
3000-
std::pair<BraceStmt *, Type>
3001-
getRuntimeDiscoverableAttributeGenerator(CustomAttr *) const;
30022985
};
30032986

30042987
/// This is a common base class for declarations which declare a type.
@@ -5996,9 +5979,6 @@ class VarDecl : public AbstractStorageDecl {
59965979
/// that has an external effect on the function.
59975980
bool hasExternalPropertyWrapper() const;
59985981

5999-
/// Whether this property has any attached runtime metadata attributes.
6000-
bool hasRuntimeMetadataAttributes() const;
6001-
60025982
/// Whether all of the attached property wrappers have an init(wrappedValue:)
60035983
/// initializer.
60045984
bool allAttachedPropertyWrappersHaveWrappedValueInit() const;

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7377,62 +7377,6 @@ ERROR(noncopyable_cannot_have_read_set_accessor,none,
73777377
"noncopyable %select{variable|subscript}0 cannot provide a read and set accessor",
73787378
(unsigned))
73797379

7380-
//------------------------------------------------------------------------------
7381-
// MARK: Runtime discoverable attributes (@runtimeMetadata)
7382-
//------------------------------------------------------------------------------
7383-
7384-
ERROR(runtime_discoverable_attrs_are_experimental,none,
7385-
"runtime discoverable attributes are an experimental feature", ())
7386-
7387-
ERROR(invalid_decl_for_runtime_discoverable_attr,none,
7388-
"@%0 can only be applied to non-generic types, methods, "
7389-
"instance properties, and global functions", (StringRef))
7390-
7391-
ERROR(invalid_decl_for_runtime_discoverable_attr_in_extension,none,
7392-
"@%0 can only be applied to unavailable extensions in the same module"
7393-
" as %1", (StringRef, DeclName))
7394-
7395-
ERROR(invalid_attr_redeclaration_in_extension,none,
7396-
"@%0 is already applied to type %1; did you want to remove it?",
7397-
(StringRef, DeclName))
7398-
7399-
ERROR(duplicate_runtime_discoverable_attr,none,
7400-
"duplicate runtime discoverable attribute", ())
7401-
7402-
ERROR(runtime_attribute_requires_init,none,
7403-
"runtime attribute type %0 does not contain a required initializer"
7404-
" - init(attachedTo:)",
7405-
(DeclName))
7406-
7407-
ERROR(runtime_attribute_type_failable_init,none,
7408-
"runtime attribute type initializer %0 cannot be failable", (DeclName))
7409-
7410-
ERROR(runtime_attribute_type_requirement_not_accessible,none,
7411-
"%select{private|fileprivate|internal|package|public|open}0 %kind1 cannot have "
7412-
"more restrictive access than its enclosing runtime attribute type %2 "
7413-
"(which is %select{private|fileprivate|internal|package|public|open}3)",
7414-
(AccessLevel, const ValueDecl *, Type, AccessLevel))
7415-
7416-
ERROR(cannot_use_attr_with_custom_arguments_on_protocol,none,
7417-
"reflection metadata attributes applied to protocols cannot have"
7418-
" additional attribute arguments; attribute arguments must be"
7419-
" explicitly written on the conforming type",
7420-
())
7421-
7422-
NOTE(missing_reflection_metadata_attribute_on_type,none,
7423-
"protocol %0 requires reflection metadata attribute @%1",
7424-
(DeclName, StringRef))
7425-
7426-
ERROR(missing_reflection_metadata_attribute_on_subclass,none,
7427-
"superclass %0 requires reflection metadata attribute @%1",
7428-
(DeclName, StringRef))
7429-
NOTE(add_missing_reflection_metadata_attr,none,
7430-
"add missing reflection metadata attribute @%0", (StringRef))
7431-
NOTE(opt_out_from_missing_reflection_metadata_attr,none,
7432-
"opt-out of reflection metadata attribute @%0 using"
7433-
" unavailable extension",
7434-
(StringRef))
7435-
74367380
//------------------------------------------------------------------------------
74377381
// MARK: Init accessors
74387382
//------------------------------------------------------------------------------

include/swift/AST/Initializer.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ enum class InitializerKind : uint8_t {
3636

3737
/// A property wrapper initialization expression.
3838
PropertyWrapper,
39-
40-
/// A runtime discoverable attribute initialization expression.
41-
RuntimeAttribute,
4239
};
4340

4441
/// An Initializer is a kind of DeclContext used for expressions that
@@ -236,35 +233,6 @@ class PropertyWrapperInitializer : public Initializer {
236233
}
237234
};
238235

239-
/// A runtime discoverable attribute initialization expression context.
240-
///
241-
/// The parent context is context of the file/module this generator is
242-
/// synthesized in.
243-
class RuntimeAttributeInitializer : public Initializer {
244-
CustomAttr *Attr;
245-
ValueDecl *AttachedTo;
246-
247-
public:
248-
explicit RuntimeAttributeInitializer(CustomAttr *attr, ValueDecl *attachedTo)
249-
: Initializer(InitializerKind::RuntimeAttribute,
250-
attachedTo->getDeclContext()),
251-
Attr(attr), AttachedTo(attachedTo) {}
252-
253-
CustomAttr *getAttr() const { return Attr; }
254-
255-
ValueDecl *getAttachedToDecl() const { return AttachedTo; }
256-
257-
static bool classof(const DeclContext *DC) {
258-
if (auto init = dyn_cast<Initializer>(DC))
259-
return classof(init);
260-
return false;
261-
}
262-
263-
static bool classof(const Initializer *I) {
264-
return I->getInitializerKind() == InitializerKind::RuntimeAttribute;
265-
}
266-
};
267-
268236
} // end namespace swift
269237

270238
#endif

include/swift/AST/SourceFile.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,6 @@ class SourceFile final : public FileUnit {
166166
/// if it were done from OpaqueResultTypeRequest.
167167
llvm::SetVector<OpaqueTypeDecl *> UnvalidatedOpaqueReturnTypes;
168168

169-
/// The set of declarations with valid runtime discoverable attributes
170-
/// located in the source file.
171-
llvm::SetVector<ValueDecl *> DeclsWithRuntimeDiscoverableAttrs;
172-
173169
/// The list of top-level items in the source file. This is \c None if
174170
/// they have not yet been parsed.
175171
/// FIXME: Once addTopLevelDecl/prependTopLevelDecl
@@ -229,10 +225,6 @@ class SourceFile final : public FileUnit {
229225
/// Add a hoisted declaration. See Decl::isHoisted().
230226
void addHoistedDecl(Decl *d);
231227

232-
/// Add a declaration with any number of runtime disoverable attributes
233-
/// associated with it.
234-
void addDeclWithRuntimeDiscoverableAttrs(ValueDecl *);
235-
236228
/// Retrieves an immutable view of the list of top-level items in this file.
237229
ArrayRef<ASTNode> getTopLevelItems() const;
238230

@@ -245,10 +237,6 @@ class SourceFile final : public FileUnit {
245237
/// See Decl::isHoisted().
246238
ArrayRef<Decl *> getHoistedDecls() const;
247239

248-
/// Retrieves an immutable view of the set of all declaration with runtime
249-
/// discoverable attributes located in this file.
250-
ArrayRef<ValueDecl *> getDeclsWithRuntimeDiscoverableAttrs() const;
251-
252240
/// Retrieves an immutable view of the top-level items if they have already
253241
/// been parsed, or \c None if they haven't. Should only be used for dumping.
254242
llvm::Optional<ArrayRef<ASTNode>> getCachedTopLevelItems() const {

include/swift/AST/TypeCheckRequests.h

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3646,10 +3646,6 @@ enum class CustomAttrTypeKind {
36463646
/// Global actors are represented as custom type attributes. They don't
36473647
/// have any particularly interesting semantics.
36483648
GlobalActor,
3649-
3650-
/// Attributes that are discoverable/constructable at runtime given a name.
3651-
/// They allow unbound generic types.
3652-
RuntimeMetadata,
36533649
};
36543650

36553651
void simple_display(llvm::raw_ostream &out, CustomAttrTypeKind value);
@@ -4242,57 +4238,6 @@ class ExternalMacroDefinitionRequest
42424238
bool isCached() const { return true; }
42434239
};
42444240

4245-
class GetRuntimeDiscoverableAttributes
4246-
: public SimpleRequest<GetRuntimeDiscoverableAttributes,
4247-
ArrayRef<CustomAttr *>(Decl *),
4248-
RequestFlags::Cached> {
4249-
public:
4250-
using SimpleRequest::SimpleRequest;
4251-
4252-
private:
4253-
friend SimpleRequest;
4254-
4255-
ArrayRef<CustomAttr *> evaluate(Evaluator &evaluator, Decl *decl) const;
4256-
4257-
public:
4258-
bool isCached() const { return true; }
4259-
};
4260-
4261-
class SynthesizeRuntimeMetadataAttrGenerator
4262-
: public SimpleRequest<SynthesizeRuntimeMetadataAttrGenerator,
4263-
Expr *(CustomAttr *, ValueDecl *),
4264-
RequestFlags::Cached> {
4265-
4266-
public:
4267-
using SimpleRequest::SimpleRequest;
4268-
4269-
private:
4270-
friend SimpleRequest;
4271-
4272-
Expr *evaluate(Evaluator &evaluator, CustomAttr *attr,
4273-
ValueDecl *attachedTo) const;
4274-
4275-
public:
4276-
bool isCached() const { return true; }
4277-
};
4278-
4279-
class SynthesizeRuntimeMetadataAttrGeneratorBody
4280-
: public SimpleRequest<SynthesizeRuntimeMetadataAttrGeneratorBody,
4281-
BraceStmt *(CustomAttr *, ValueDecl *),
4282-
RequestFlags::Cached> {
4283-
public:
4284-
using SimpleRequest::SimpleRequest;
4285-
4286-
private:
4287-
friend SimpleRequest;
4288-
4289-
BraceStmt *evaluate(Evaluator &evaluator, CustomAttr *attr,
4290-
ValueDecl *attachedTo) const;
4291-
4292-
public:
4293-
bool isCached() const { return true; }
4294-
};
4295-
42964241
/// Compute the local discriminators for the given declaration context.
42974242
///
42984243
/// This is a state-changing operation for closures within the context, which

0 commit comments

Comments
 (0)