18
18
#define SWIFT_DECL_H
19
19
20
20
#include " swift/AST/AccessScope.h"
21
+ #include " swift/AST/Attr.h"
21
22
#include " swift/AST/CaptureInfo.h"
22
23
#include " swift/AST/ClangNode.h"
23
24
#include " swift/AST/ConcreteDeclRef.h"
@@ -286,8 +287,12 @@ class alignas(1 << DeclAlignInBits) Decl {
286
287
// / Whether we have already checked whether this declaration is a
287
288
// / redeclaration.
288
289
unsigned CheckedRedeclaration : 1 ;
290
+
291
+ // / Whether the decl can be accessed by swift users; for instance,
292
+ // / a.storage for lazy var a is a decl that cannot be accessed.
293
+ unsigned IsUserAccessible : 1 ;
289
294
};
290
- enum { NumValueDeclBits = NumDeclBits + 2 };
295
+ enum { NumValueDeclBits = NumDeclBits + 3 };
291
296
static_assert (NumValueDeclBits <= 32 , " fits in an unsigned" );
292
297
293
298
class AbstractStorageDeclBitfields {
@@ -327,11 +332,8 @@ class alignas(1 << DeclAlignInBits) Decl {
327
332
// / It is up to the debugger to instruct SIL how to access this variable.
328
333
unsigned IsDebuggerVar : 1 ;
329
334
330
- // / Whether the decl can be accessed by swift users; for instance,
331
- // / a.storage for lazy var a is a decl that cannot be accessed.
332
- unsigned IsUserAccessible : 1 ;
333
335
};
334
- enum { NumVarDeclBits = NumAbstractStorageDeclBits + 6 };
336
+ enum { NumVarDeclBits = NumAbstractStorageDeclBits + 5 };
335
337
static_assert (NumVarDeclBits <= 32 , " fits in an unsigned" );
336
338
337
339
class EnumElementDeclBitfields {
@@ -383,10 +385,8 @@ class alignas(1 << DeclAlignInBits) Decl {
383
385
// / Whether this function has a dynamic Self return type.
384
386
unsigned HasDynamicSelf : 1 ;
385
387
386
- // / Whether we are statically dispatched even if overridable
387
- unsigned ForcedStaticDispatch : 1 ;
388
388
};
389
- enum { NumFuncDeclBits = NumAbstractFunctionDeclBits + 6 };
389
+ enum { NumFuncDeclBits = NumAbstractFunctionDeclBits + 5 };
390
390
static_assert (NumFuncDeclBits <= 32 , " fits in an unsigned" );
391
391
392
392
class ConstructorDeclBitfields {
@@ -400,9 +400,6 @@ class alignas(1 << DeclAlignInBits) Decl {
400
400
// / analysis and SIL generation.
401
401
unsigned ComputedBodyInitKind : 3 ;
402
402
403
- // / The kind of initializer we have.
404
- unsigned InitKind : 2 ;
405
-
406
403
// / Whether this initializer is a stub placed into a subclass to
407
404
// / catch invalid delegations to a designated initializer not
408
405
// / overridden by the subclass. A stub will always trap at runtime.
@@ -412,7 +409,7 @@ class alignas(1 << DeclAlignInBits) Decl {
412
409
// / an object construction that will invoke a stub.
413
410
unsigned HasStubImplementation : 1 ;
414
411
};
415
- enum { NumConstructorDeclBits = NumAbstractFunctionDeclBits + 6 };
412
+ enum { NumConstructorDeclBits = NumAbstractFunctionDeclBits + 4 };
416
413
static_assert (NumConstructorDeclBits <= 32 , " fits in an unsigned" );
417
414
418
415
class TypeDeclBitfields {
@@ -523,10 +520,8 @@ class alignas(1 << DeclAlignInBits) Decl {
523
520
// / control inserting the implicit destructor.
524
521
unsigned HasDestructorDecl : 1 ;
525
522
526
- // / Whether the class has @objc ancestry.
527
- unsigned ObjCClassKind : 3 ;
528
523
};
529
- enum { NumClassDeclBits = NumNominalTypeDeclBits + 11 };
524
+ enum { NumClassDeclBits = NumNominalTypeDeclBits + 8 };
530
525
static_assert (NumClassDeclBits <= 32 , " fits in an unsigned" );
531
526
532
527
class StructDeclBitfields {
@@ -2090,6 +2085,7 @@ class ValueDecl : public Decl {
2090
2085
: Decl(K, context), Name(name), NameLoc(NameLoc) {
2091
2086
ValueDeclBits.AlreadyInLookupTable = false ;
2092
2087
ValueDeclBits.CheckedRedeclaration = false ;
2088
+ ValueDeclBits.IsUserAccessible = true ;
2093
2089
}
2094
2090
2095
2091
public:
@@ -2115,6 +2111,14 @@ class ValueDecl : public Decl {
2115
2111
ValueDeclBits.CheckedRedeclaration = checked;
2116
2112
}
2117
2113
2114
+ void setUserAccessible (bool Accessible) {
2115
+ ValueDeclBits.IsUserAccessible = Accessible;
2116
+ }
2117
+
2118
+ bool isUserAccessible () const {
2119
+ return ValueDeclBits.IsUserAccessible ;
2120
+ }
2121
+
2118
2122
bool hasName () const { return bool (Name); }
2119
2123
// / TODO: Rename to getSimpleName?
2120
2124
Identifier getName () const { return Name.getBaseName (); }
@@ -3182,6 +3186,9 @@ class ClassDecl : public NominalTypeDecl {
3182
3186
SourceLoc ClassLoc;
3183
3187
ObjCMethodLookupTable *ObjCMethodLookup = nullptr ;
3184
3188
3189
+ // / Whether the class has @objc ancestry.
3190
+ unsigned ObjCKind : 3 ;
3191
+
3185
3192
// / Create the Objective-C member lookup table.
3186
3193
void createObjCMethodLookup ();
3187
3194
@@ -3795,7 +3802,7 @@ struct alignas(1 << 3) BehaviorRecord {
3795
3802
: ProtocolName (ProtocolName), Param (Param)
3796
3803
{}
3797
3804
3798
- SourceLoc getLoc () const { return ProtocolName-> getLoc (); }
3805
+ SourceLoc getLoc () const ;
3799
3806
};
3800
3807
3801
3808
// / AbstractStorageDecl - This is the common superclass for VarDecl and
@@ -4277,7 +4284,6 @@ class VarDecl : public AbstractStorageDecl {
4277
4284
SourceLoc NameLoc, Identifier Name, Type Ty, DeclContext *DC)
4278
4285
: AbstractStorageDecl(Kind, DC, Name, NameLoc)
4279
4286
{
4280
- VarDeclBits.IsUserAccessible = true ;
4281
4287
VarDeclBits.IsStatic = IsStatic;
4282
4288
VarDeclBits.IsLet = IsLet;
4283
4289
VarDeclBits.IsCaptureList = IsCaptureList;
@@ -4299,14 +4305,6 @@ class VarDecl : public AbstractStorageDecl {
4299
4305
4300
4306
SourceRange getSourceRange () const ;
4301
4307
4302
- void setUserAccessible (bool Accessible) {
4303
- VarDeclBits.IsUserAccessible = Accessible;
4304
- }
4305
-
4306
- bool isUserAccessible () const {
4307
- return VarDeclBits.IsUserAccessible ;
4308
- }
4309
-
4310
4308
TypeLoc &getTypeLoc () { return typeLoc; }
4311
4309
TypeLoc getTypeLoc () const { return typeLoc; }
4312
4310
@@ -5030,6 +5028,9 @@ class FuncDecl final : public AbstractFunctionDecl,
5030
5028
unsigned HaveSearchedForCommonOverloadReturnType : 1 ;
5031
5029
unsigned HaveFoundCommonOverloadReturnType : 1 ;
5032
5030
5031
+ // / Whether we are statically dispatched even if overridable
5032
+ unsigned ForcedStaticDispatch : 1 ;
5033
+
5033
5034
// / \brief If this FuncDecl is an accessor for a property, this indicates
5034
5035
// / which property and what kind of accessor.
5035
5036
llvm::PointerIntPair<AbstractStorageDecl*, 3 , AccessorKind> AccessorDecl;
@@ -5059,8 +5060,8 @@ class FuncDecl final : public AbstractFunctionDecl,
5059
5060
assert (NumParameterLists > 0 && " Must have at least an empty tuple arg" );
5060
5061
FuncDeclBits.Mutating = false ;
5061
5062
FuncDeclBits.HasDynamicSelf = false ;
5062
- FuncDeclBits. ForcedStaticDispatch = false ;
5063
-
5063
+
5064
+ ForcedStaticDispatch = false ;
5064
5065
HaveSearchedForCommonOverloadReturnType = false ;
5065
5066
HaveFoundCommonOverloadReturnType = false ;
5066
5067
}
@@ -5290,10 +5291,10 @@ class FuncDecl final : public AbstractFunctionDecl,
5290
5291
5291
5292
// / Returns true if the function is forced to be statically dispatched.
5292
5293
bool hasForcedStaticDispatch () const {
5293
- return FuncDeclBits. ForcedStaticDispatch ;
5294
+ return ForcedStaticDispatch;
5294
5295
}
5295
5296
void setForcedStaticDispatch (bool flag) {
5296
- FuncDeclBits. ForcedStaticDispatch = flag;
5297
+ ForcedStaticDispatch = flag;
5297
5298
}
5298
5299
5299
5300
static bool classof (const Decl *D) { return D->getKind () == DeclKind::Func; }
@@ -5510,6 +5511,9 @@ enum class CtorInitializerKind {
5510
5511
// / }
5511
5512
// / \endcode
5512
5513
class ConstructorDecl : public AbstractFunctionDecl {
5514
+ // / The kind of initializer we have.
5515
+ unsigned InitKind : 2 ;
5516
+
5513
5517
// / The failability of this initializer, which is an OptionalTypeKind.
5514
5518
unsigned Failability : 2 ;
5515
5519
@@ -5615,12 +5619,12 @@ class ConstructorDecl : public AbstractFunctionDecl {
5615
5619
5616
5620
// / Determine the kind of initializer this is.
5617
5621
CtorInitializerKind getInitKind () const {
5618
- return static_cast <CtorInitializerKind>(ConstructorDeclBits. InitKind );
5622
+ return static_cast <CtorInitializerKind>(InitKind);
5619
5623
}
5620
5624
5621
5625
// / Set whether this is a convenience initializer.
5622
5626
void setInitKind (CtorInitializerKind kind) {
5623
- ConstructorDeclBits. InitKind = static_cast <unsigned >(kind);
5627
+ InitKind = static_cast <unsigned >(kind);
5624
5628
}
5625
5629
5626
5630
// / Whether this is a designated initializer.
0 commit comments