@@ -4771,6 +4771,10 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
47714771 getTypeOfKeyPathComponent),
47724772 Ctx (ctx), DC(dc) {}
47734773
4774+ bool isTypeChecked () const {
4775+ return PrintBase::isTypeChecked () && DC;
4776+ }
4777+
47744778 void printCommon (DeclAttribute *Attr, StringRef name, Label label) {
47754779 printHead (name, DeclAttributeColor, label);
47764780 printFlag (Attr->isImplicit (), " implicit" );
@@ -5005,7 +5009,7 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
50055009
50065010 if (Attr->getType ()) {
50075011 printTypeField (Attr->getType (), Label::always (" type" ));
5008- } else if (MemberLoading == ASTDumpMemberLoading::TypeChecked ) {
5012+ } else if (isTypeChecked () ) {
50095013 // If the type is null, it might be a macro reference. Try that if we're
50105014 // dumping the fully type-checked AST.
50115015 auto macroRef =
@@ -5360,6 +5364,43 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
53605364
53615365} // end anonymous namespace
53625366
5367+ void DeclAttribute::dump (const ASTContext &ctx) const {
5368+ dump (llvm::errs (), ctx);
5369+ llvm::errs () << ' \n ' ;
5370+ }
5371+
5372+ void DeclAttribute::dump (llvm::raw_ostream &os, const ASTContext &ctx) const {
5373+ DefaultWriter writer (os, /* indent=*/ 0 );
5374+ PrintAttribute (writer, &ctx, nullptr )
5375+ .visit (const_cast <DeclAttribute*>(this ), Label::optional (" " ));
5376+ }
5377+
5378+ void DeclAttribute::dump (const DeclContext *dc) const {
5379+ dump (llvm::errs (), dc);
5380+ llvm::errs () << ' \n ' ;
5381+ }
5382+
5383+ void DeclAttribute::dump (llvm::raw_ostream &os, const DeclContext *dc) const {
5384+ DefaultWriter writer (os, /* indent=*/ 0 );
5385+ PrintAttribute (writer, &dc->getASTContext (), const_cast <DeclContext*>(dc))
5386+ .visit (const_cast <DeclAttribute*>(this ), Label::optional (" " ));
5387+ }
5388+
5389+
5390+ void DeclAttributes::dump (const ASTContext &ctx) const {
5391+ for (auto attr : *this ) {
5392+ attr->dump (llvm::errs (), ctx);
5393+ llvm::errs () << ' \n ' ;
5394+ }
5395+ }
5396+
5397+ void DeclAttributes::dump (const DeclContext *dc) const {
5398+ for (auto attr : *this ) {
5399+ attr->dump (llvm::errs (), dc);
5400+ llvm::errs () << ' \n ' ;
5401+ }
5402+ }
5403+
53635404void PrintBase::printRec (Decl *D, Label label) {
53645405 printRecArbitrary ([&](Label label) {
53655406 if (!D) {
0 commit comments