Skip to content

Commit 46f95d6

Browse files
committed
Include source ranges for parameter lists in the AST dump.
1 parent 28af695 commit 46f95d6

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ namespace {
990990
PrintWithColorRAII(OS, ParenthesisColor) << ')';
991991
}
992992

993-
void printParameterList(const ParameterList *params) {
993+
void printParameterList(const ParameterList *params, const ASTContext *ctx = nullptr) {
994994
OS.indent(Indent);
995995
PrintWithColorRAII(OS, ParenthesisColor) << '(';
996996
PrintWithColorRAII(OS, ParameterColor) << "parameter_list";
@@ -999,6 +999,19 @@ namespace {
999999
OS << '\n';
10001000
printParameter(P);
10011001
}
1002+
1003+
if (!ctx && params->size() != 0 && params->get(0))
1004+
ctx = &params->get(0)->getASTContext();
1005+
1006+
if (ctx) {
1007+
auto R = params->getSourceRange();
1008+
if (R.isValid()) {
1009+
PrintWithColorRAII(OS, RangeColor) << " range=";
1010+
R.print(PrintWithColorRAII(OS, RangeColor).getOS(),
1011+
ctx->SourceMgr, /*PrintText=*/false);
1012+
}
1013+
}
1014+
10021015
PrintWithColorRAII(OS, ParenthesisColor) << ')';
10031016
Indent -= 2;
10041017
}
@@ -1007,7 +1020,7 @@ namespace {
10071020
for (auto pl : D->getParameterLists()) {
10081021
OS << '\n';
10091022
Indent += 2;
1010-
printParameterList(pl);
1023+
printParameterList(pl, &D->getASTContext());
10111024
Indent -= 2;
10121025
}
10131026
if (auto FD = dyn_cast<FuncDecl>(D)) {
@@ -2280,7 +2293,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
22802293

22812294
if (E->getParameters()) {
22822295
OS << '\n';
2283-
PrintDecl(OS, Indent+2).printParameterList(E->getParameters());
2296+
PrintDecl(OS, Indent+2).printParameterList(E->getParameters(), &E->getASTContext());
22842297
}
22852298

22862299
OS << '\n';
@@ -2296,7 +2309,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
22962309

22972310
if (E->getParameters()) {
22982311
OS << '\n';
2299-
PrintDecl(OS, Indent+2).printParameterList(E->getParameters());
2312+
PrintDecl(OS, Indent+2).printParameterList(E->getParameters(), &E->getASTContext());
23002313
}
23012314

23022315
OS << '\n';

0 commit comments

Comments
 (0)