@@ -425,7 +425,7 @@ namespace {
425
425
426
426
void printRec (Decl *D) { D->dump (OS, Indent + 2 ); }
427
427
void printRec (Expr *E) { E->print (OS, Indent + 2 ); }
428
- void printRec (Stmt *S, const ASTContext &Ctx ) { S->print (OS, &Ctx , Indent + 2 ); }
428
+ void printRec (Stmt *S) { S->print (OS, Indent + 2 ); }
429
429
void printRec (TypeRepr *T);
430
430
void printRec (const Pattern *P) {
431
431
PrintPattern (OS, Indent+2 ).visit (const_cast <Pattern *>(P));
@@ -553,7 +553,7 @@ namespace {
553
553
554
554
void printRec (Decl *D) { PrintDecl (OS, Indent + 2 ).visit (D); }
555
555
void printRec (Expr *E) { E->print (OS, Indent+2 ); }
556
- void printRec (Stmt *S, const ASTContext &Ctx ) { S->print (OS, &Ctx , Indent+2 ); }
556
+ void printRec (Stmt *S) { S->print (OS, Indent+2 ); }
557
557
void printRec (Pattern *P) { PrintPattern (OS, Indent+2 ).visit (P); }
558
558
void printRec (TypeRepr *T);
559
559
@@ -575,13 +575,6 @@ namespace {
575
575
if (D->isImplicit ())
576
576
PrintWithColorRAII (OS, DeclModifierColor) << " implicit" ;
577
577
578
- auto R = D->getSourceRange ();
579
- if (R.isValid ()) {
580
- PrintWithColorRAII (OS, RangeColor) << " range=" ;
581
- R.print (PrintWithColorRAII (OS, RangeColor).getOS (),
582
- D->getASTContext ().SourceMgr , /* PrintText=*/ false );
583
- }
584
-
585
578
if (D->TrailingSemiLoc .isValid ())
586
579
PrintWithColorRAII (OS, DeclModifierColor) << " trailing_semi" ;
587
580
}
@@ -991,7 +984,7 @@ namespace {
991
984
PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
992
985
}
993
986
994
- void printParameterList (const ParameterList *params, const ASTContext *ctx = nullptr ) {
987
+ void printParameterList (const ParameterList *params) {
995
988
OS.indent (Indent);
996
989
PrintWithColorRAII (OS, ParenthesisColor) << ' (' ;
997
990
PrintWithColorRAII (OS, ParameterColor) << " parameter_list" ;
@@ -1000,19 +993,6 @@ namespace {
1000
993
OS << ' \n ' ;
1001
994
printParameter (P);
1002
995
}
1003
-
1004
- if (!ctx && params->size () != 0 && params->get (0 ))
1005
- ctx = ¶ms->get (0 )->getASTContext ();
1006
-
1007
- if (ctx) {
1008
- auto R = params->getSourceRange ();
1009
- if (R.isValid ()) {
1010
- PrintWithColorRAII (OS, RangeColor) << " range=" ;
1011
- R.print (PrintWithColorRAII (OS, RangeColor).getOS (),
1012
- ctx->SourceMgr , /* PrintText=*/ false );
1013
- }
1014
- }
1015
-
1016
996
PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
1017
997
Indent -= 2 ;
1018
998
}
@@ -1021,7 +1001,7 @@ namespace {
1021
1001
for (auto pl : D->getParameterLists ()) {
1022
1002
OS << ' \n ' ;
1023
1003
Indent += 2 ;
1024
- printParameterList (pl, &D-> getASTContext () );
1004
+ printParameterList (pl);
1025
1005
Indent -= 2 ;
1026
1006
}
1027
1007
if (auto FD = dyn_cast<FuncDecl>(D)) {
@@ -1038,7 +1018,7 @@ namespace {
1038
1018
}
1039
1019
if (auto Body = D->getBody (/* canSynthesize=*/ false )) {
1040
1020
OS << ' \n ' ;
1041
- printRec (Body, D-> getASTContext () );
1021
+ printRec (Body);
1042
1022
}
1043
1023
}
1044
1024
@@ -1085,12 +1065,12 @@ namespace {
1085
1065
printCommon (TLCD, " top_level_code_decl" );
1086
1066
if (TLCD->getBody ()) {
1087
1067
OS << " \n " ;
1088
- printRec (TLCD->getBody (), static_cast <Decl *>(TLCD)-> getASTContext () );
1068
+ printRec (TLCD->getBody ());
1089
1069
}
1090
1070
PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
1091
1071
}
1092
1072
1093
- void printASTNodes (const ArrayRef<ASTNode> &Elements, const ASTContext &Ctx, StringRef Name) {
1073
+ void printASTNodes (const ArrayRef<ASTNode> &Elements, StringRef Name) {
1094
1074
OS.indent (Indent);
1095
1075
PrintWithColorRAII (OS, ParenthesisColor) << " (" ;
1096
1076
PrintWithColorRAII (OS, ASTNodeColor) << Name;
@@ -1099,7 +1079,7 @@ namespace {
1099
1079
if (auto *SubExpr = Elt.dyn_cast <Expr*>())
1100
1080
printRec (SubExpr);
1101
1081
else if (auto *SubStmt = Elt.dyn_cast <Stmt*>())
1102
- printRec (SubStmt, Ctx );
1082
+ printRec (SubStmt);
1103
1083
else
1104
1084
printRec (Elt.get <Decl*>());
1105
1085
}
@@ -1122,7 +1102,7 @@ namespace {
1122
1102
1123
1103
OS << ' \n ' ;
1124
1104
Indent += 2 ;
1125
- printASTNodes (Clause.Elements , ICD-> getASTContext (), " elements" );
1105
+ printASTNodes (Clause.Elements , " elements" );
1126
1106
Indent -= 2 ;
1127
1107
}
1128
1108
@@ -1369,11 +1349,9 @@ namespace {
1369
1349
class PrintStmt : public StmtVisitor <PrintStmt> {
1370
1350
public:
1371
1351
raw_ostream &OS;
1372
- const ASTContext *Ctx;
1373
1352
unsigned Indent;
1374
1353
1375
- PrintStmt (raw_ostream &os, const ASTContext *ctx, unsigned indent)
1376
- : OS(os), Ctx(ctx), Indent(indent) {
1354
+ PrintStmt (raw_ostream &os, unsigned indent) : OS(os), Indent(indent) {
1377
1355
}
1378
1356
1379
1357
void printRec (Stmt *S) {
@@ -1440,28 +1418,20 @@ class PrintStmt : public StmtVisitor<PrintStmt> {
1440
1418
if (S->isImplicit ())
1441
1419
OS << " implicit" ;
1442
1420
1443
- if (Ctx) {
1444
- auto R = S->getSourceRange ();
1445
- if (R.isValid ()) {
1446
- PrintWithColorRAII (OS, RangeColor) << " range=" ;
1447
- R.print (PrintWithColorRAII (OS, RangeColor).getOS (),
1448
- Ctx->SourceMgr , /* PrintText=*/ false );
1449
- }
1450
- }
1451
-
1452
1421
if (S->TrailingSemiLoc .isValid ())
1453
1422
OS << " trailing_semi" ;
1454
1423
1455
1424
return OS;
1456
1425
}
1457
1426
1458
1427
void visitBraceStmt (BraceStmt *S) {
1459
- printCommon (S, " brace_stmt" );
1460
- printASTNodes (S->getElements ());
1461
- PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
1428
+ printASTNodes (S->getElements (), " brace_stmt" );
1462
1429
}
1463
1430
1464
- void printASTNodes (const ArrayRef<ASTNode> &Elements) {
1431
+ void printASTNodes (const ArrayRef<ASTNode> &Elements, StringRef Name) {
1432
+ OS.indent (Indent);
1433
+ PrintWithColorRAII (OS, ParenthesisColor) << " (" ;
1434
+ PrintWithColorRAII (OS, ASTNodeColor) << Name;
1465
1435
for (auto Elt : Elements) {
1466
1436
OS << ' \n ' ;
1467
1437
if (auto *SubExpr = Elt.dyn_cast <Expr*>())
@@ -1471,6 +1441,7 @@ class PrintStmt : public StmtVisitor<PrintStmt> {
1471
1441
else
1472
1442
printRec (Elt.get <Decl*>());
1473
1443
}
1444
+ PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
1474
1445
}
1475
1446
1476
1447
void visitReturnStmt (ReturnStmt *S) {
@@ -1654,8 +1625,8 @@ void Stmt::dump() const {
1654
1625
llvm::errs () << ' \n ' ;
1655
1626
}
1656
1627
1657
- void Stmt::print (raw_ostream &OS, const ASTContext *Ctx, unsigned Indent) const {
1658
- PrintStmt (OS, Ctx, Indent).visit (const_cast <Stmt*>(this ));
1628
+ void Stmt::print (raw_ostream &OS, unsigned Indent) const {
1629
+ PrintStmt (OS, Indent).visit (const_cast <Stmt*>(this ));
1659
1630
}
1660
1631
1661
1632
// ===----------------------------------------------------------------------===//
@@ -1700,7 +1671,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
1700
1671
// / FIXME: This should use ExprWalker to print children.
1701
1672
1702
1673
void printRec (Decl *D) { D->dump (OS, Indent + 2 ); }
1703
- void printRec (Stmt *S, const ASTContext &Ctx ) { S->print (OS, &Ctx , Indent + 2 ); }
1674
+ void printRec (Stmt *S) { S->print (OS, Indent + 2 ); }
1704
1675
void printRec (const Pattern *P) {
1705
1676
PrintPattern (OS, Indent+2 ).visit (const_cast <Pattern *>(P));
1706
1677
}
@@ -2303,14 +2274,14 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
2303
2274
2304
2275
if (E->getParameters ()) {
2305
2276
OS << ' \n ' ;
2306
- PrintDecl (OS, Indent+2 ).printParameterList (E->getParameters (), &E-> getASTContext () );
2277
+ PrintDecl (OS, Indent+2 ).printParameterList (E->getParameters ());
2307
2278
}
2308
2279
2309
2280
OS << ' \n ' ;
2310
2281
if (E->hasSingleExpressionBody ()) {
2311
2282
printRec (E->getSingleExpressionBody ());
2312
2283
} else {
2313
- printRec (E->getBody (), E-> getASTContext () );
2284
+ printRec (E->getBody ());
2314
2285
}
2315
2286
PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
2316
2287
}
@@ -2319,7 +2290,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
2319
2290
2320
2291
if (E->getParameters ()) {
2321
2292
OS << ' \n ' ;
2322
- PrintDecl (OS, Indent+2 ).printParameterList (E->getParameters (), &E-> getASTContext () );
2293
+ PrintDecl (OS, Indent+2 ).printParameterList (E->getParameters ());
2323
2294
}
2324
2295
2325
2296
OS << ' \n ' ;
0 commit comments