@@ -4799,6 +4799,10 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
4799
4799
getTypeOfKeyPathComponent),
4800
4800
Ctx (ctx), DC(dc) {}
4801
4801
4802
+ bool isTypeChecked () const {
4803
+ return PrintBase::isTypeChecked () && DC;
4804
+ }
4805
+
4802
4806
void printCommon (DeclAttribute *Attr, StringRef name, Label label) {
4803
4807
printHead (name, DeclAttributeColor, label);
4804
4808
printFlag (Attr->isImplicit (), " implicit" );
@@ -5027,7 +5031,7 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
5027
5031
5028
5032
if (Attr->getType ()) {
5029
5033
printTypeField (Attr->getType (), Label::always (" type" ));
5030
- } else if (MemberLoading == ASTDumpMemberLoading::TypeChecked ) {
5034
+ } else if (isTypeChecked () ) {
5031
5035
// If the type is null, it might be a macro reference. Try that if we're
5032
5036
// dumping the fully type-checked AST.
5033
5037
auto macroRef =
@@ -5382,6 +5386,43 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
5382
5386
5383
5387
} // end anonymous namespace
5384
5388
5389
+ void DeclAttribute::dump (const ASTContext &ctx) const {
5390
+ dump (llvm::errs (), ctx);
5391
+ llvm::errs () << ' \n ' ;
5392
+ }
5393
+
5394
+ void DeclAttribute::dump (llvm::raw_ostream &os, const ASTContext &ctx) const {
5395
+ DefaultWriter writer (os, /* indent=*/ 0 );
5396
+ PrintAttribute (writer, &ctx, nullptr )
5397
+ .visit (const_cast <DeclAttribute*>(this ), Label::optional (" " ));
5398
+ }
5399
+
5400
+ void DeclAttribute::dump (const DeclContext *dc) const {
5401
+ dump (llvm::errs (), dc);
5402
+ llvm::errs () << ' \n ' ;
5403
+ }
5404
+
5405
+ void DeclAttribute::dump (llvm::raw_ostream &os, const DeclContext *dc) const {
5406
+ DefaultWriter writer (os, /* indent=*/ 0 );
5407
+ PrintAttribute (writer, &dc->getASTContext (), const_cast <DeclContext*>(dc))
5408
+ .visit (const_cast <DeclAttribute*>(this ), Label::optional (" " ));
5409
+ }
5410
+
5411
+
5412
+ void DeclAttributes::dump (const ASTContext &ctx) const {
5413
+ for (auto attr : *this ) {
5414
+ attr->dump (llvm::errs (), ctx);
5415
+ llvm::errs () << ' \n ' ;
5416
+ }
5417
+ }
5418
+
5419
+ void DeclAttributes::dump (const DeclContext *dc) const {
5420
+ for (auto attr : *this ) {
5421
+ attr->dump (llvm::errs (), dc);
5422
+ llvm::errs () << ' \n ' ;
5423
+ }
5424
+ }
5425
+
5385
5426
void PrintBase::printRec (Decl *D, Label label) {
5386
5427
printRecArbitrary ([&](Label label) {
5387
5428
if (!D) {
0 commit comments