@@ -4771,6 +4771,10 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
4771
4771
getTypeOfKeyPathComponent),
4772
4772
Ctx (ctx), DC(dc) {}
4773
4773
4774
+ bool isTypeChecked () const {
4775
+ return PrintBase::isTypeChecked () && DC;
4776
+ }
4777
+
4774
4778
void printCommon (DeclAttribute *Attr, StringRef name, Label label) {
4775
4779
printHead (name, DeclAttributeColor, label);
4776
4780
printFlag (Attr->isImplicit (), " implicit" );
@@ -5005,7 +5009,7 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
5005
5009
5006
5010
if (Attr->getType ()) {
5007
5011
printTypeField (Attr->getType (), Label::always (" type" ));
5008
- } else if (MemberLoading == ASTDumpMemberLoading::TypeChecked ) {
5012
+ } else if (isTypeChecked () ) {
5009
5013
// If the type is null, it might be a macro reference. Try that if we're
5010
5014
// dumping the fully type-checked AST.
5011
5015
auto macroRef =
@@ -5360,6 +5364,43 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
5360
5364
5361
5365
} // end anonymous namespace
5362
5366
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
+
5363
5404
void PrintBase::printRec (Decl *D, Label label) {
5364
5405
printRecArbitrary ([&](Label label) {
5365
5406
if (!D) {
0 commit comments