@@ -3585,6 +3585,29 @@ bool HasStorageRequest::evaluate(Evaluator &evaluator,
35853585 return hasStorage;
35863586}
35873587
3588+ llvm::Optional<bool > HasStorageRequest::getCachedResult () const {
3589+ AbstractStorageDecl *decl = std::get<0 >(getStorage ());
3590+ if (decl->LazySemanticInfo .HasStorageComputed )
3591+ return static_cast <bool >(decl->LazySemanticInfo .HasStorage );
3592+ return llvm::None;
3593+ }
3594+
3595+ void HasStorageRequest::cacheResult (bool hasStorage) const {
3596+ AbstractStorageDecl *decl = std::get<0 >(getStorage ());
3597+ decl->LazySemanticInfo .HasStorageComputed = true ;
3598+ decl->LazySemanticInfo .HasStorage = hasStorage;
3599+
3600+ // Add an attribute for printing, but only to VarDecls.
3601+ if (isa<ParamDecl>(decl))
3602+ return ;
3603+
3604+ if (auto varDecl = dyn_cast<VarDecl>(decl)) {
3605+ if (hasStorage && !varDecl->getAttrs ().hasAttribute <HasStorageAttr>())
3606+ varDecl->getAttrs ().add (new (varDecl->getASTContext ())
3607+ HasStorageAttr (/* isImplicit=*/ true ));
3608+ }
3609+ }
3610+
35883611StorageImplInfo
35893612StorageImplInfoRequest::evaluate (Evaluator &evaluator,
35903613 AbstractStorageDecl *storage) const {
@@ -3598,7 +3621,7 @@ StorageImplInfoRequest::evaluate(Evaluator &evaluator,
35983621 if (auto *var = dyn_cast<VarDecl>(storage)) {
35993622 // Allow the @_hasStorage attribute to override all the accessors we parsed
36003623 // when making the final classification.
3601- if (var->getAttrs ().hasAttribute <HasStorageAttr>()) {
3624+ if (var->getParsedAttrs ().hasAttribute <HasStorageAttr>()) {
36023625 // The SIL rules for @_hasStorage are slightly different from the non-SIL
36033626 // rules. In SIL mode, @_hasStorage marks that the type is simply stored,
36043627 // and the only thing that determines mutability is the existence of the
0 commit comments