@@ -357,7 +357,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
357357 // for the inline bitfields.
358358 union { uint64_t OpaqueBits;
359359
360- SWIFT_INLINE_BITFIELD_BASE (Decl, bitmax (NumDeclKindBits,8 )+1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 ,
360+ SWIFT_INLINE_BITFIELD_BASE (Decl, bitmax (NumDeclKindBits,8 )+1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 + 1 ,
361361 Kind : bitmax (NumDeclKindBits,8 ),
362362
363363 // / Whether this declaration is invalid.
@@ -372,10 +372,6 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
372372 // / Use getClangNode() to retrieve the corresponding Clang AST.
373373 FromClang : 1 ,
374374
375- // / Whether this declaration was added to the surrounding
376- // / DeclContext of an active #if config clause.
377- EscapedFromIfConfig : 1 ,
378-
379375 // / Whether this declaration is syntactically scoped inside of
380376 // / a local context, but should behave like a top-level
381377 // / declaration for name lookup purposes. This is used by
@@ -404,7 +400,13 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
404400
405401 // / True if we're in the common case where the SPIGroupsRequest
406402 // / request returned an empty array of identifiers.
407- NoSPIGroups : 1
403+ NoSPIGroups : 1 ,
404+
405+ // / True if we have computed whether this declaration is unsafe.
406+ IsUnsafeComputed : 1 ,
407+
408+ // / True if this declaration has been determined to be "unsafe".
409+ IsUnsafe : 1
408410 );
409411
410412 SWIFT_INLINE_BITFIELD_FULL (PatternBindingDecl, Decl, 1 +1 +2 +16 ,
@@ -857,6 +859,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
857859 friend class ExpandPeerMacroRequest ;
858860 friend class GlobalActorAttributeRequest ;
859861 friend class SPIGroupsRequest ;
862+ friend class IsUnsafeRequest ;
860863
861864private:
862865 llvm::PointerUnion<DeclContext *, ASTContext *> Context;
@@ -916,12 +919,13 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
916919 Bits.Decl .Invalid = false ;
917920 Bits.Decl .Implicit = false ;
918921 Bits.Decl .FromClang = false ;
919- Bits.Decl .EscapedFromIfConfig = false ;
920922 Bits.Decl .Hoisted = false ;
921923 Bits.Decl .LacksObjCInterfaceOrImplementation = false ;
922924 Bits.Decl .NoMemberAttributeMacros = false ;
923925 Bits.Decl .NoGlobalActorAttribute = false ;
924926 Bits.Decl .NoSPIGroups = false ;
927+ Bits.Decl .IsUnsafeComputed = false ;
928+ Bits.Decl .IsUnsafe = false ;
925929 }
926930
927931 // / Get the Clang node associated with this declaration.
@@ -1180,15 +1184,26 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
11801184 // / Whether this declaration predates the introduction of concurrency.
11811185 bool preconcurrency () const ;
11821186
1183- public:
1184- bool escapedFromIfConfig () const {
1185- return Bits.Decl .EscapedFromIfConfig ;
1187+ // / Whether this declaration is considered "unsafe", i.e., should not be
1188+ // / used in a "safe" dialect.
1189+ bool isUnsafe () const ;
1190+
1191+ private:
1192+ bool isUnsafeComputed () const {
1193+ return Bits.Decl .IsUnsafeComputed ;
1194+ }
1195+
1196+ bool isUnsafeRaw () const {
1197+ return Bits.Decl .IsUnsafe ;
11861198 }
11871199
1188- void setEscapedFromIfConfig (bool Escaped) {
1189- Bits.Decl .EscapedFromIfConfig = Escaped;
1200+ void setUnsafe (bool value) {
1201+ assert (!Bits.Decl .IsUnsafeComputed );
1202+ Bits.Decl .IsUnsafe = value;
1203+ Bits.Decl .IsUnsafeComputed = true ;
11901204 }
11911205
1206+ public:
11921207 bool getSemanticAttrsComputed () const {
11931208 return Bits.Decl .SemanticAttrsComputed ;
11941209 }
0 commit comments