@@ -89,6 +89,9 @@ class SemaAnnotator : public ASTWalker {
8989
9090 bool handleImports (ImportDecl *Import);
9191 bool handleCustomAttributes (Decl *D);
92+ bool handleCustomTypeAttribute (const CustomAttr *customAttr);
93+ bool handleClosureAttributes (ClosureExpr *E);
94+ bool handleTypeAttributes (AttributedTypeRepr *T);
9295 bool passModulePathElements (ImportPath::Module Path,
9396 const clang::Module *ClangMod);
9497
@@ -603,6 +606,10 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
603606 return Action::Stop ();
604607 }
605608 }
609+ } else if (auto CE = dyn_cast<ClosureExpr>(E)) {
610+ if (!handleClosureAttributes (CE))
611+ return Action::Stop ();
612+ return Action::Continue (E);
606613 }
607614
608615 return Action::Continue (E);
@@ -655,6 +662,9 @@ ASTWalker::PreWalkAction SemaAnnotator::walkToTypeReprPre(TypeRepr *T) {
655662 ST->getSourceRange (), Data);
656663 return Action::StopIf (!Continue);
657664 }
665+ } else if (auto AT = dyn_cast<AttributedTypeRepr>(T)) {
666+ auto Continue = handleTypeAttributes (AT);
667+ return Action::StopIf (!Continue);
658668 }
659669
660670 return Action::Continue ();
@@ -762,6 +772,39 @@ bool SemaAnnotator::handleCustomAttributes(Decl *D) {
762772 return true ;
763773}
764774
775+ bool SemaAnnotator::handleCustomTypeAttribute (const CustomAttr *customAttr) {
776+ if (auto *Repr = customAttr->getTypeRepr ())
777+ if (!Repr->walk (*this ))
778+ return false ;
779+
780+ if (auto *Args = customAttr->getArgs ())
781+ if (!Args->walk (*this ))
782+ return false ;
783+
784+ return true ;
785+ }
786+
787+ bool SemaAnnotator::handleClosureAttributes (ClosureExpr *E) {
788+ for (auto *customAttr : E->getAttrs ().getAttributes <CustomAttr, true >())
789+ if (!handleCustomTypeAttribute (customAttr))
790+ return false ;
791+
792+ return true ;
793+ }
794+
795+ bool SemaAnnotator::handleTypeAttributes (AttributedTypeRepr *T) {
796+ for (auto attr : T->getAttrs ()) {
797+ if (!attr.is <CustomAttr *>())
798+ continue ;
799+
800+ CustomAttr *customAttr = attr.get <CustomAttr *>();
801+ if (!handleCustomTypeAttribute (customAttr))
802+ return false ;
803+ }
804+
805+ return true ;
806+ }
807+
765808bool SemaAnnotator::handleImports (ImportDecl *Import) {
766809 auto Mod = Import->getModule ();
767810 if (!Mod)
0 commit comments