@@ -355,7 +355,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
355355 // for the inline bitfields.
356356 union { uint64_t OpaqueBits;
357357
358- SWIFT_INLINE_BITFIELD_BASE (Decl, bitmax (NumDeclKindBits,8 )+1 +1 +1 +1 +1 +1 ,
358+ SWIFT_INLINE_BITFIELD_BASE (Decl, bitmax (NumDeclKindBits,8 )+1 +1 +1 +1 +1 +1 + 1 ,
359359 Kind : bitmax (NumDeclKindBits,8 ),
360360
361361 // / Whether this declaration is invalid.
@@ -381,7 +381,12 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
381381 Hoisted : 1 ,
382382
383383 // / Whether the set of semantic attributes has been computed.
384- SemanticAttrsComputed : 1
384+ SemanticAttrsComputed : 1 ,
385+
386+ // / True if \c ObjCInterfaceAndImplementationRequest has been computed
387+ // / and did \em not find anything. This is the fast path where we can bail
388+ // / out without checking other caches or computing anything.
389+ LacksObjCInterfaceOrImplementation : 1
385390 );
386391
387392 SWIFT_INLINE_BITFIELD_FULL (PatternBindingDecl, Decl, 1 +1 +2 +16 ,
@@ -816,13 +821,6 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
816821private:
817822 llvm::PointerUnion<DeclContext *, ASTContext *> Context;
818823
819- // / The imported Clang declaration representing the \c @_objcInterface for
820- // / this declaration (or vice versa), or \c nullptr if there is none.
821- // /
822- // / If \c this (an otherwise nonsensical value), the value has not yet been
823- // / computed.
824- Decl *CachedObjCImplementationDecl;
825-
826824 Decl (const Decl&) = delete ;
827825 void operator =(const Decl&) = delete ;
828826 SourceLoc getLocFromSource () const ;
@@ -840,14 +838,15 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
840838protected:
841839
842840 Decl (DeclKind kind, llvm::PointerUnion<DeclContext *, ASTContext *> context)
843- : Context (context), CachedObjCImplementationDecl ( this ) {
841+ : Context (context) {
844842 Bits.OpaqueBits = 0 ;
845843 Bits.Decl .Kind = unsigned (kind);
846844 Bits.Decl .Invalid = false ;
847845 Bits.Decl .Implicit = false ;
848846 Bits.Decl .FromClang = false ;
849847 Bits.Decl .EscapedFromIfConfig = false ;
850848 Bits.Decl .Hoisted = false ;
849+ Bits.Decl .LacksObjCInterfaceOrImplementation = false ;
851850 }
852851
853852 // / Get the Clang node associated with this declaration.
@@ -1179,18 +1178,12 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
11791178 // / \seeAlso ExtensionDecl::isObjCInterface()
11801179 Decl *getObjCImplementationDecl () const ;
11811180
1182- llvm::Optional<Decl *> getCachedObjCImplementationDecl () const {
1183- if (CachedObjCImplementationDecl == this )
1184- return llvm::None;
1185- return CachedObjCImplementationDecl;
1181+ bool getCachedLacksObjCInterfaceOrImplementation () const {
1182+ return Bits.Decl .LacksObjCInterfaceOrImplementation ;
11861183 }
11871184
1188- void setCachedObjCImplementationDecl (Decl *decl) {
1189- assert ((CachedObjCImplementationDecl == this
1190- || CachedObjCImplementationDecl == decl)
1191- && " can't change CachedObjCInterfaceDecl once it's computed" );
1192- assert (decl != this && " can't form circular reference" );
1193- CachedObjCImplementationDecl = decl;
1185+ void setCachedLacksObjCInterfaceOrImplementation (bool value) {
1186+ Bits.Decl .LacksObjCInterfaceOrImplementation = value;
11941187 }
11951188
11961189 // / Return the GenericContext if the Decl has one.
0 commit comments