@@ -89,6 +89,9 @@ class SemaAnnotator : public ASTWalker {
89
89
90
90
bool handleImports (ImportDecl *Import);
91
91
bool handleCustomAttributes (Decl *D);
92
+ bool handleCustomTypeAttribute (const CustomAttr *customAttr);
93
+ bool handleClosureAttributes (ClosureExpr *E);
94
+ bool handleTypeAttributes (AttributedTypeRepr *T);
92
95
bool passModulePathElements (ImportPath::Module Path,
93
96
const clang::Module *ClangMod);
94
97
@@ -603,6 +606,10 @@ ASTWalker::PreWalkResult<Expr *> SemaAnnotator::walkToExprPre(Expr *E) {
603
606
return Action::Stop ();
604
607
}
605
608
}
609
+ } else if (auto CE = dyn_cast<ClosureExpr>(E)) {
610
+ if (!handleClosureAttributes (CE))
611
+ return Action::Stop ();
612
+ return Action::Continue (E);
606
613
}
607
614
608
615
return Action::Continue (E);
@@ -655,6 +662,9 @@ ASTWalker::PreWalkAction SemaAnnotator::walkToTypeReprPre(TypeRepr *T) {
655
662
ST->getSourceRange (), Data);
656
663
return Action::StopIf (!Continue);
657
664
}
665
+ } else if (auto AT = dyn_cast<AttributedTypeRepr>(T)) {
666
+ auto Continue = handleTypeAttributes (AT);
667
+ return Action::StopIf (!Continue);
658
668
}
659
669
660
670
return Action::Continue ();
@@ -762,6 +772,39 @@ bool SemaAnnotator::handleCustomAttributes(Decl *D) {
762
772
return true ;
763
773
}
764
774
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
+
765
808
bool SemaAnnotator::handleImports (ImportDecl *Import) {
766
809
auto Mod = Import->getModule ();
767
810
if (!Mod)
0 commit comments