Skip to content

Commit 918f74b

Browse files
committed
[ASTDumper][NFC] Omit most blank names
Allows us to more easily audit these later for e.g. JSON support.
1 parent 4931a8f commit 918f74b

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ class PrintBase {
512512

513513
printRec(arg.getExpr());
514514
printFoot();
515-
}, "");
515+
});
516516
}
517517

518518
void printRec(const ArgumentList *argList, StringRef label = "") {
@@ -586,7 +586,7 @@ class PrintBase {
586586
SmallPtrSet<const ProtocolConformance *, 4> Dumped;
587587
dumpSubstitutionMapRec(map, OS, SubstitutionMap::DumpStyle::Full,
588588
Indent, Dumped);
589-
}, "");
589+
});
590590
}
591591

592592
void printRec(ProtocolConformanceRef conf, StringRef label = "") {
@@ -620,6 +620,13 @@ class PrintBase {
620620
color);
621621
}
622622

623+
624+
// Print a field with a value.
625+
template<typename Fn>
626+
void printFlagRaw(Fn body, TerminalColor color = FieldLabelColor) {
627+
printFieldRaw(body, "", color);
628+
}
629+
623630
// Print a single flag.
624631
void printFlag(StringRef name, TerminalColor color = FieldLabelColor) {
625632
printField(name, "", color);
@@ -994,11 +1001,11 @@ class PrintBase {
9941001
printFlag(attrs.hasAttribute<ObjCAttr>(), "@objc");
9951002
printFlag(attrs.hasAttribute<DynamicAttr>(), "dynamic");
9961003
if (auto *attr = attrs.getAttribute<DynamicReplacementAttr>()) {
997-
printFieldRaw([&](raw_ostream &OS) {
1004+
printFlagRaw([&](raw_ostream &OS) {
9981005
OS << "@_dynamicReplacement(for: \"";
9991006
OS << attr->getReplacedFunctionName();
10001007
OS << "\")";
1001-
}, "");
1008+
});
10021009
}
10031010
auto lifetimeString = getDumpString(VD->getLifetimeAnnotation());
10041011
if (!lifetimeString.empty())
@@ -1214,9 +1221,9 @@ class PrintBase {
12141221
void printCommonAFD(AbstractFunctionDecl *D, const char *Type, StringRef Label) {
12151222
printCommon(D, Type, Label, FuncColor);
12161223
if (!D->getCaptureInfo().isTrivial()) {
1217-
printFieldRaw([&](raw_ostream &OS) {
1224+
printFlagRaw([&](raw_ostream &OS) {
12181225
D->getCaptureInfo().print(OS);
1219-
}, "");
1226+
});
12201227
}
12211228

12221229
printFlag(D->getAttrs().hasAttribute<NonisolatedAttr>(), "nonisolated",
@@ -1250,7 +1257,7 @@ class PrintBase {
12501257
if (auto errorParamIndex = fac->completionHandlerErrorParamIndex())
12511258
printField(*errorParamIndex, "error_param");
12521259
printFoot();
1253-
}, "");
1260+
});
12541261
}
12551262

12561263
if (auto fec = D->getForeignErrorConvention()) {
@@ -1269,7 +1276,7 @@ class PrintBase {
12691276
if (wantResultType)
12701277
printField(fec->getResultType(), "resulttype");
12711278
printFoot();
1272-
}, "");
1279+
});
12731280
}
12741281

12751282
if (D->hasSingleExpressionBody()) {
@@ -1335,7 +1342,7 @@ class PrintBase {
13351342

13361343
void visitIfConfigDecl(IfConfigDecl *ICD, StringRef label) {
13371344
printCommon(ICD, "if_config_decl", label);
1338-
printRecRange(ICD->getClauses(), &ICD->getASTContext(), "");
1345+
printRecRange(ICD->getClauses(), &ICD->getASTContext(), "clauses");
13391346
printFoot();
13401347
}
13411348

@@ -1360,7 +1367,7 @@ class PrintBase {
13601367
for (auto &rel : rels)
13611368
printFlag(rel.Name.str());
13621369
printFoot();
1363-
}, "");
1370+
});
13641371
};
13651372
printRelationsRec(PGD->getHigherThan(), "higherThan");
13661373
printRelationsRec(PGD->getLowerThan(), "lowerThan");
@@ -1773,7 +1780,7 @@ class PrintStmt : public StmtVisitor<PrintStmt, void, StringRef>,
17731780
}
17741781

17751782
printFoot();
1776-
}, "");
1783+
});
17771784
}
17781785

17791786
printRec(S->getBody());
@@ -1805,17 +1812,10 @@ class PrintStmt : public StmtVisitor<PrintStmt, void, StringRef>,
18051812

18061813
void visitDoCatchStmt(DoCatchStmt *S, StringRef label) {
18071814
printCommon(S, "do_catch_stmt", label);
1808-
printRec(S->getBody());
1809-
visitCatches(S->getCatches());
1815+
printRec(S->getBody(), "body");
1816+
printRecRange(S->getCatches(), Ctx, "catch_stmts");
18101817
printFoot();
18111818
}
1812-
void visitCatches(ArrayRef<CaseStmt *> clauses) {
1813-
for (auto clause : clauses) {
1814-
printRecRaw([&](StringRef label) {
1815-
visitCaseStmt(clause, label);
1816-
}, "");
1817-
}
1818-
}
18191819
};
18201820

18211821
} // end anonymous namespace
@@ -2049,7 +2049,7 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, StringRef>,
20492049
printHead("candidate_decl", DeclModifierColor, label);
20502050
printNameRaw([&](raw_ostream &OS) { D->dumpRef(OS); });
20512051
printFoot();
2052-
}, "");
2052+
});
20532053
}
20542054
}
20552055

@@ -2158,7 +2158,7 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, StringRef>,
21582158
printRecRaw([&](StringRef label) {
21592159
printHead("<tuple element default value>", ExprColor);
21602160
printFoot();
2161-
}, "");
2161+
});
21622162
}
21632163
}
21642164

@@ -2852,11 +2852,11 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, StringRef>,
28522852
printRec(args);
28532853
}
28542854
printFoot();
2855-
}, "");
2855+
});
28562856
}
28572857

28582858
printFoot();
2859-
}, "");
2859+
});
28602860

28612861
if (auto stringLiteral = E->getObjCStringLiteralExpr()) {
28622862
printRec(stringLiteral, "objc_string_literal");
@@ -3208,7 +3208,7 @@ class PrintTypeRepr : public TypeReprVisitor<PrintTypeRepr, void, StringRef>,
32083208

32093209
printRec(Field.getFieldType());
32103210
printFoot();
3211-
}, "");
3211+
});
32123212
}
32133213

32143214
printRecRange(T->getGenericArguments(), "generic_arguments");
@@ -3749,7 +3749,7 @@ namespace {
37493749
printField(elt.getName().str(), "name");
37503750
printRec(elt.getType());
37513751
printFoot();
3752-
}, "");
3752+
});
37533753
}
37543754

37553755
printFoot();
@@ -3932,7 +3932,7 @@ namespace {
39323932
printRec(param.getPlainType());
39333933

39343934
printFoot();
3935-
}, "");
3935+
});
39363936
}
39373937
printFoot();
39383938
}, label);
@@ -3948,7 +3948,7 @@ namespace {
39483948
info.dump(OS, clangCtx);
39493949
});
39503950
printFoot();
3951-
}, "");
3951+
});
39523952
}
39533953
}
39543954

0 commit comments

Comments
 (0)