@@ -365,8 +365,14 @@ class alignas(1 << DeclAlignInBits) Decl {
365
365
366
366
// / Whether the function body throws.
367
367
unsigned Throws : 1 ;
368
+
369
+ // / Whether this function requires a new vtable entry.
370
+ unsigned NeedsNewVTableEntry : 1 ;
371
+
372
+ // / Whether NeedsNewVTableEntry is valid.
373
+ unsigned HasComputedNeedsNewVTableEntry : 1 ;
368
374
};
369
- enum { NumAbstractFunctionDeclBits = NumValueDeclBits + 11 };
375
+ enum { NumAbstractFunctionDeclBits = NumValueDeclBits + 13 };
370
376
static_assert (NumAbstractFunctionDeclBits <= 32 , " fits in an unsigned" );
371
377
372
378
class FuncDeclBitfields {
@@ -378,15 +384,8 @@ class alignas(1 << DeclAlignInBits) Decl {
378
384
379
385
// / \brief Whether 'static' or 'class' was used.
380
386
unsigned StaticSpelling : 2 ;
381
-
382
- // / Whether this function is a 'mutating' method.
383
- unsigned Mutating : 1 ;
384
-
385
- // / Whether this function has a dynamic Self return type.
386
- unsigned HasDynamicSelf : 1 ;
387
-
388
387
};
389
- enum { NumFuncDeclBits = NumAbstractFunctionDeclBits + 5 };
388
+ enum { NumFuncDeclBits = NumAbstractFunctionDeclBits + 3 };
390
389
static_assert (NumFuncDeclBits <= 32 , " fits in an unsigned" );
391
390
392
391
class ConstructorDeclBitfields {
@@ -399,17 +398,8 @@ class alignas(1 << DeclAlignInBits) Decl {
399
398
// / of the definition of the constructor that is useful only to semantic
400
399
// / analysis and SIL generation.
401
400
unsigned ComputedBodyInitKind : 3 ;
402
-
403
- // / Whether this initializer is a stub placed into a subclass to
404
- // / catch invalid delegations to a designated initializer not
405
- // / overridden by the subclass. A stub will always trap at runtime.
406
- // /
407
- // / Initializer stubs can be invoked from Objective-C or through
408
- // / the Objective-C runtime; there is no way to directly express
409
- // / an object construction that will invoke a stub.
410
- unsigned HasStubImplementation : 1 ;
411
401
};
412
- enum { NumConstructorDeclBits = NumAbstractFunctionDeclBits + 4 };
402
+ enum { NumConstructorDeclBits = NumAbstractFunctionDeclBits + 3 };
413
403
static_assert (NumConstructorDeclBits <= 32 , " fits in an unsigned" );
414
404
415
405
class TypeDeclBitfields {
@@ -4790,6 +4780,8 @@ class AbstractFunctionDecl : public ValueDecl, public GenericContext {
4790
4780
AbstractFunctionDeclBits.NumParameterLists = NumParameterLists;
4791
4781
AbstractFunctionDeclBits.Overridden = false ;
4792
4782
AbstractFunctionDeclBits.Throws = Throws;
4783
+ AbstractFunctionDeclBits.NeedsNewVTableEntry = false ;
4784
+ AbstractFunctionDeclBits.HasComputedNeedsNewVTableEntry = false ;
4793
4785
4794
4786
// Verify no bitfield truncation.
4795
4787
assert (AbstractFunctionDeclBits.NumParameterLists == NumParameterLists);
@@ -4903,6 +4895,21 @@ class AbstractFunctionDecl : public ValueDecl, public GenericContext {
4903
4895
return getBodyKind () == BodyKind::MemberwiseInitializer;
4904
4896
}
4905
4897
4898
+ void setNeedsNewVTableEntry (bool value) {
4899
+ AbstractFunctionDeclBits.HasComputedNeedsNewVTableEntry = true ;
4900
+ AbstractFunctionDeclBits.NeedsNewVTableEntry = value;
4901
+ }
4902
+
4903
+ bool needsNewVTableEntry () const {
4904
+ if (!AbstractFunctionDeclBits.HasComputedNeedsNewVTableEntry )
4905
+ const_cast <AbstractFunctionDecl *>(this )->computeNeedsNewVTableEntry ();
4906
+ return AbstractFunctionDeclBits.NeedsNewVTableEntry ;
4907
+ }
4908
+
4909
+ private:
4910
+ void computeNeedsNewVTableEntry ();
4911
+
4912
+ public:
4906
4913
// / Retrieve the source range of the function body.
4907
4914
SourceRange getBodySourceRange () const ;
4908
4915
@@ -5059,6 +5066,12 @@ class FuncDecl final : public AbstractFunctionDecl,
5059
5066
// / Whether we are statically dispatched even if overridable
5060
5067
unsigned ForcedStaticDispatch : 1 ;
5061
5068
5069
+ // / Whether this function has a dynamic Self return type.
5070
+ unsigned HasDynamicSelf : 1 ;
5071
+
5072
+ // / Whether this function is a 'mutating' method.
5073
+ unsigned Mutating : 1 ;
5074
+
5062
5075
// / \brief If this FuncDecl is an accessor for a property, this indicates
5063
5076
// / which property and what kind of accessor.
5064
5077
llvm::PointerIntPair<AbstractStorageDecl*, 3 , AccessorKind> AccessorDecl;
@@ -5086,9 +5099,9 @@ class FuncDecl final : public AbstractFunctionDecl,
5086
5099
StaticLoc.isValid () || StaticSpelling != StaticSpellingKind::None;
5087
5100
FuncDeclBits.StaticSpelling = static_cast <unsigned >(StaticSpelling);
5088
5101
assert (NumParameterLists > 0 && " Must have at least an empty tuple arg" );
5089
- FuncDeclBits.Mutating = false ;
5090
- FuncDeclBits.HasDynamicSelf = false ;
5091
5102
5103
+ Mutating = false ;
5104
+ HasDynamicSelf = false ;
5092
5105
ForcedStaticDispatch = false ;
5093
5106
HaveSearchedForCommonOverloadReturnType = false ;
5094
5107
HaveFoundCommonOverloadReturnType = false ;
@@ -5141,10 +5154,10 @@ class FuncDecl final : public AbstractFunctionDecl,
5141
5154
FuncDeclBits.IsStatic = IsStatic;
5142
5155
}
5143
5156
bool isMutating () const {
5144
- return FuncDeclBits. Mutating ;
5157
+ return Mutating;
5145
5158
}
5146
- void setMutating (bool Mutating = true ) {
5147
- FuncDeclBits. Mutating = Mutating ;
5159
+ void setMutating (bool mutating = true ) {
5160
+ Mutating = mutating ;
5148
5161
}
5149
5162
5150
5163
// / \brief Returns the parameter lists(s) for the function definition.
@@ -5266,11 +5279,11 @@ class FuncDecl final : public AbstractFunctionDecl,
5266
5279
5267
5280
// / Determine whether this function has a dynamic \c Self return
5268
5281
// / type.
5269
- bool hasDynamicSelf () const { return FuncDeclBits. HasDynamicSelf ; }
5282
+ bool hasDynamicSelf () const { return HasDynamicSelf; }
5270
5283
5271
5284
// / Set whether this function has a dynamic \c Self return or not.
5272
5285
void setDynamicSelf (bool hasDynamicSelf) {
5273
- FuncDeclBits. HasDynamicSelf = hasDynamicSelf;
5286
+ HasDynamicSelf = hasDynamicSelf;
5274
5287
}
5275
5288
5276
5289
void getLocalCaptures (SmallVectorImpl<CapturedValue> &Result) const {
@@ -5549,6 +5562,15 @@ class ConstructorDecl : public AbstractFunctionDecl {
5549
5562
// / The failability of this initializer, which is an OptionalTypeKind.
5550
5563
unsigned Failability : 2 ;
5551
5564
5565
+ // / Whether this initializer is a stub placed into a subclass to
5566
+ // / catch invalid delegations to a designated initializer not
5567
+ // / overridden by the subclass. A stub will always trap at runtime.
5568
+ // /
5569
+ // / Initializer stubs can be invoked from Objective-C or through
5570
+ // / the Objective-C runtime; there is no way to directly express
5571
+ // / an object construction that will invoke a stub.
5572
+ unsigned HasStubImplementation : 1 ;
5573
+
5552
5574
// / The location of the '!' or '?' for a failable initializer.
5553
5575
SourceLoc FailabilityLoc;
5554
5576
@@ -5708,13 +5730,13 @@ class ConstructorDecl : public AbstractFunctionDecl {
5708
5730
5709
5731
// / Whether the implementation of this method is a stub that traps at runtime.
5710
5732
bool hasStubImplementation () const {
5711
- return ConstructorDeclBits. HasStubImplementation ;
5733
+ return HasStubImplementation;
5712
5734
}
5713
5735
5714
5736
// / Set whether the implementation of this method is a stub that
5715
5737
// / traps at runtime.
5716
5738
void setStubImplementation (bool stub) {
5717
- ConstructorDeclBits. HasStubImplementation = stub;
5739
+ HasStubImplementation = stub;
5718
5740
}
5719
5741
5720
5742
ConstructorDecl *getOverriddenDecl () const { return OverriddenDecl; }
0 commit comments