File tree Expand file tree Collapse file tree 10 files changed +42
-3
lines changed Expand file tree Collapse file tree 10 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,8 @@ class DeclBaseName {
214
214
public:
215
215
enum class Kind : uint8_t {
216
216
Normal,
217
- Subscript
217
+ Subscript,
218
+ Destructor
218
219
};
219
220
220
221
private:
@@ -223,6 +224,8 @@ class DeclBaseName {
223
224
// / This is an implementation detail that should never leak outside of
224
225
// / DeclName.
225
226
static void *SubscriptIdentifierData;
227
+ // / As above, for special destructor DeclNames.
228
+ static void *DestructorIdentifierData;
226
229
227
230
Identifier Ident;
228
231
@@ -235,9 +238,15 @@ class DeclBaseName {
235
238
return DeclBaseName (Identifier ((const char *)SubscriptIdentifierData));
236
239
}
237
240
241
+ static DeclBaseName createDestructor () {
242
+ return DeclBaseName (Identifier ((const char *)DestructorIdentifierData));
243
+ }
244
+
238
245
Kind getKind () const {
239
246
if (Ident.get () == SubscriptIdentifierData) {
240
247
return Kind::Subscript;
248
+ } else if (Ident.get () == DestructorIdentifierData) {
249
+ return Kind::Destructor;
241
250
} else {
242
251
return Kind::Normal;
243
252
}
@@ -273,6 +282,8 @@ class DeclBaseName {
273
282
return getIdentifier ().str ();
274
283
case Kind::Subscript:
275
284
return " subscript" ;
285
+ case Kind::Destructor:
286
+ return " deinit" ;
276
287
}
277
288
}
278
289
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ const uint16_t VERSION_MAJOR = 0;
54
54
// / in source control, you should also update the comment to briefly
55
55
// / describe what change you made. The content of this comment isn't important;
56
56
// / it just ensures a conflict if two people change the module format.
57
- const uint16_t VERSION_MINOR = 353 ; // Last change: count inherited conformances
57
+ const uint16_t VERSION_MINOR = 354 ; // Last change: special destructor names
58
58
59
59
using DeclID = PointerEmbeddedInt<unsigned , 31 >;
60
60
using DeclIDField = BCFixed<31 >;
@@ -345,7 +345,8 @@ using OptionalTypeKindField = BCFixed<2>;
345
345
// VERSION_MAJOR.
346
346
enum class DeclNameKind : uint8_t {
347
347
Normal,
348
- Subscript
348
+ Subscript,
349
+ Destructor
349
350
};
350
351
351
352
// These IDs must \em not be renumbered or reordered without incrementing
@@ -359,6 +360,8 @@ enum SpecialIdentifierID : uint8_t {
359
360
OBJC_HEADER_MODULE_ID,
360
361
// / Special value for the special subscript name
361
362
SUBSCRIPT_ID,
363
+ // / Special value for the special destructor name
364
+ DESTRUCTOR_ID,
362
365
363
366
// / The number of special Identifier IDs. This value should never be encoded;
364
367
// / it should only be used to count the number of names above. As such, it
Original file line number Diff line number Diff line change @@ -548,6 +548,8 @@ void ASTMangler::appendDeclName(const ValueDecl *decl) {
548
548
case DeclBaseName::Kind::Subscript:
549
549
appendIdentifier (" subscript" );
550
550
break ;
551
+ case DeclBaseName::Kind::Destructor:
552
+ llvm_unreachable (" Destructors are not mangled using appendDeclName" );
551
553
}
552
554
} else {
553
555
assert (AllowNamelessEntities && " attempt to mangle unnamed decl" );
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ using namespace swift;
22
22
23
23
void *DeclBaseName::SubscriptIdentifierData =
24
24
&DeclBaseName::SubscriptIdentifierData;
25
+ void *DeclBaseName::DestructorIdentifierData =
26
+ &DeclBaseName::DestructorIdentifierData;
25
27
26
28
raw_ostream &llvm::operator <<(raw_ostream &OS, Identifier I) {
27
29
if (I.get () == nullptr )
Original file line number Diff line number Diff line change @@ -211,6 +211,8 @@ DeclBaseName SerializedSwiftName::toDeclBaseName(ASTContext &Context) const {
211
211
return Context.getIdentifier (Name);
212
212
case DeclBaseName::Kind::Subscript:
213
213
return DeclBaseName::createSubscript ();
214
+ case DeclBaseName::Kind::Destructor:
215
+ return DeclBaseName::createDestructor ();
214
216
}
215
217
}
216
218
@@ -829,6 +831,9 @@ void SwiftLookupTable::dump() const {
829
831
case DeclBaseName::Kind::Subscript:
830
832
llvm::errs () << " subscript:\n " ;
831
833
break ;
834
+ case DeclBaseName::Kind::Destructor:
835
+ llvm::errs () << " deinit:\n " ;
836
+ break ;
832
837
}
833
838
const auto &entries = LookupTable.find (baseName)->second ;
834
839
for (const auto &entry : entries) {
Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ struct SerializedSwiftName {
82
82
return Name;
83
83
case DeclBaseName::Kind::Subscript:
84
84
return " subscript" ;
85
+ case DeclBaseName::Kind::Destructor:
86
+ return " deinit" ;
85
87
}
86
88
}
87
89
Original file line number Diff line number Diff line change @@ -1621,6 +1621,8 @@ static SelectorFamily getSelectorFamily(SILDeclRef c) {
1621
1621
return getSelectorFamily (declName.getIdentifier ());
1622
1622
case DeclBaseName::Kind::Subscript:
1623
1623
return SelectorFamily::None;
1624
+ case DeclBaseName::Kind::Destructor:
1625
+ return SelectorFamily::None;
1624
1626
}
1625
1627
}
1626
1628
return SelectorFamily::None;
Original file line number Diff line number Diff line change @@ -1623,6 +1623,8 @@ DeclBaseName ModuleFile::getDeclBaseName(IdentifierID IID) {
1623
1623
llvm_unreachable (" Cannot get DeclBaseName of special module id" );
1624
1624
case SUBSCRIPT_ID:
1625
1625
return DeclBaseName::createSubscript ();
1626
+ case serialization::DESTRUCTOR_ID:
1627
+ return DeclBaseName::createDestructor ();
1626
1628
case NUM_SPECIAL_IDS:
1627
1629
llvm_unreachable (" implementation detail only" );
1628
1630
}
@@ -1805,6 +1807,7 @@ ModuleDecl *ModuleFile::getModule(ModuleID MID) {
1805
1807
return clangImporter->getImportedHeaderModule ();
1806
1808
}
1807
1809
case SUBSCRIPT_ID:
1810
+ case DESTRUCTOR_ID:
1808
1811
llvm_unreachable (" Modules cannot be named with special names" );
1809
1812
case NUM_SPECIAL_IDS:
1810
1813
llvm_unreachable (" implementation detail only" );
Original file line number Diff line number Diff line change @@ -341,6 +341,8 @@ class ModuleFile::DeclTableInfo {
341
341
}
342
342
case static_cast <uint8_t >(DeclNameKind::Subscript):
343
343
return {DeclBaseName::Kind::Subscript, StringRef ()};
344
+ case static_cast <uint8_t >(DeclNameKind::Destructor):
345
+ return {DeclBaseName::Kind::Destructor, StringRef ()};
344
346
default :
345
347
llvm_unreachable (" Unknown DeclNameKind" );
346
348
}
Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ namespace {
91
91
return llvm::HashString (key.getIdentifier ().str ());
92
92
case DeclBaseName::Kind::Subscript:
93
93
return static_cast <uint8_t >(DeclNameKind::Subscript);
94
+ case DeclBaseName::Kind::Destructor:
95
+ return static_cast <uint8_t >(DeclNameKind::Destructor);
94
96
}
95
97
}
96
98
@@ -119,6 +121,9 @@ namespace {
119
121
case DeclBaseName::Kind::Subscript:
120
122
writer.write <uint8_t >(static_cast <uint8_t >(DeclNameKind::Subscript));
121
123
break ;
124
+ case DeclBaseName::Kind::Destructor:
125
+ writer.write <uint8_t >(static_cast <uint8_t >(DeclNameKind::Destructor));
126
+ break ;
122
127
}
123
128
}
124
129
@@ -509,6 +514,8 @@ IdentifierID Serializer::addDeclBaseNameRef(DeclBaseName ident) {
509
514
}
510
515
case DeclBaseName::Kind::Subscript:
511
516
return SUBSCRIPT_ID;
517
+ case DeclBaseName::Kind::Destructor:
518
+ return DESTRUCTOR_ID;
512
519
}
513
520
}
514
521
You can’t perform that action at this time.
0 commit comments