@@ -4781,6 +4781,10 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
4781
4781
getTypeOfKeyPathComponent),
4782
4782
Ctx (ctx), DC(dc) {}
4783
4783
4784
+ bool isTypeChecked () const {
4785
+ return PrintBase::isTypeChecked () && DC;
4786
+ }
4787
+
4784
4788
void printCommon (DeclAttribute *Attr, StringRef name, Label label) {
4785
4789
printHead (name, DeclAttributeColor, label);
4786
4790
printFlag (Attr->isImplicit (), " implicit" );
@@ -5015,7 +5019,7 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
5015
5019
5016
5020
if (Attr->getType ()) {
5017
5021
printTypeField (Attr->getType (), Label::always (" type" ));
5018
- } else if (MemberLoading == ASTDumpMemberLoading::TypeChecked ) {
5022
+ } else if (isTypeChecked () ) {
5019
5023
// If the type is null, it might be a macro reference. Try that if we're
5020
5024
// dumping the fully type-checked AST.
5021
5025
auto macroRef =
@@ -5370,6 +5374,43 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
5370
5374
5371
5375
} // end anonymous namespace
5372
5376
5377
+ void DeclAttribute::dump (const ASTContext &ctx) const {
5378
+ dump (llvm::errs (), ctx);
5379
+ llvm::errs () << ' \n ' ;
5380
+ }
5381
+
5382
+ void DeclAttribute::dump (llvm::raw_ostream &os, const ASTContext &ctx) const {
5383
+ DefaultWriter writer (os, /* indent=*/ 0 );
5384
+ PrintAttribute (writer, &ctx, nullptr )
5385
+ .visit (const_cast <DeclAttribute*>(this ), Label::optional (" " ));
5386
+ }
5387
+
5388
+ void DeclAttribute::dump (const DeclContext *dc) const {
5389
+ dump (llvm::errs (), dc);
5390
+ llvm::errs () << ' \n ' ;
5391
+ }
5392
+
5393
+ void DeclAttribute::dump (llvm::raw_ostream &os, const DeclContext *dc) const {
5394
+ DefaultWriter writer (os, /* indent=*/ 0 );
5395
+ PrintAttribute (writer, &dc->getASTContext (), const_cast <DeclContext*>(dc))
5396
+ .visit (const_cast <DeclAttribute*>(this ), Label::optional (" " ));
5397
+ }
5398
+
5399
+
5400
+ void DeclAttributes::dump (const ASTContext &ctx) const {
5401
+ for (auto attr : *this ) {
5402
+ attr->dump (llvm::errs (), ctx);
5403
+ llvm::errs () << ' \n ' ;
5404
+ }
5405
+ }
5406
+
5407
+ void DeclAttributes::dump (const DeclContext *dc) const {
5408
+ for (auto attr : *this ) {
5409
+ attr->dump (llvm::errs (), dc);
5410
+ llvm::errs () << ' \n ' ;
5411
+ }
5412
+ }
5413
+
5373
5414
void PrintBase::printRec (Decl *D, Label label) {
5374
5415
printRecArbitrary ([&](Label label) {
5375
5416
if (!D) {
0 commit comments