Skip to content

Commit 1ec8492

Browse files
committed
Address more reviewer feedback.
1 parent cfb99b5 commit 1ec8492

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,21 @@ namespace {
20562056
printCommonPost(PD);
20572057
}
20582058

2059-
void printGenericParameters(GenericParamList *Params) {
2059+
void printGenericSignature(const GenericSignature &Sig, Label label) {
2060+
if (!Sig)
2061+
return;
2062+
2063+
printRecArbitrary([&](Label label) {
2064+
printHead("generic_signature", ASTNodeColor, label);
2065+
printList(Sig.getGenericParams(), [&](auto GP, Label label) {
2066+
printTypeField(GP, label);
2067+
}, Label::always("generic_params"));
2068+
printGenericRequirements(Sig.getRequirements());
2069+
printFoot();
2070+
}, label);
2071+
}
2072+
2073+
void printParsedGenericParams(GenericParamList *Params) {
20602074
if (!Params)
20612075
return;
20622076

@@ -2093,20 +2107,13 @@ namespace {
20932107
printCommon((Decl*)VD, Name, label, Color);
20942108

20952109
printDeclName(VD, Label::optional("name"));
2096-
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(VD)) {
2097-
printGenericParameters(AFD->getParsedGenericParams());
2098-
if (AFD->hasComputedGenericSignature())
2099-
printGenericRequirements(AFD->getGenericRequirements());
2100-
}
2101-
if (auto *GTD = dyn_cast<GenericTypeDecl>(VD)) {
2102-
printGenericParameters(GTD->getParsedGenericParams());
2103-
if (GTD->hasComputedGenericSignature())
2104-
printGenericRequirements(GTD->getGenericRequirements());
2105-
}
2106-
if (auto *MD = dyn_cast<MacroDecl>(VD)) {
2107-
printGenericParameters(MD->getParsedGenericParams());
2108-
if (MD->hasComputedGenericSignature())
2109-
printGenericRequirements(MD->getGenericRequirements());
2110+
if (auto *GC = VD->getAsGenericContext()) {
2111+
if (Writer.isParsable() && GC->hasComputedGenericSignature()) {
2112+
printGenericSignature(GC->getGenericSignature(),
2113+
Label::optional("generic_signature"));
2114+
} else {
2115+
printParsedGenericParams(GC->getParsedGenericParams());
2116+
}
21102117
}
21112118

21122119
if (VD->hasInterfaceType()) {
@@ -2269,11 +2276,7 @@ namespace {
22692276
}
22702277

22712278
void printStorageImpl(AbstractStorageDecl *D) {
2272-
// Use a different label for the parsable outputs because "type: true" is
2273-
// confusing, especially when we also have keys elsewhere named "type"
2274-
// that are type USRs.
2275-
printFlag(D->isStatic(), Writer.isParsable() ? "static" : "type",
2276-
DeclModifierColor);
2279+
printFlag(D->isStatic(), "static", DeclModifierColor);
22772280

22782281
if (D->hasInterfaceType()) {
22792282
auto impl = D->getImplInfo();
@@ -2511,10 +2514,7 @@ namespace {
25112514

25122515
void printCommonFD(FuncDecl *FD, const char *type, Label label) {
25132516
printCommonAFD(FD, type, label);
2514-
// Use a different label for the parsable outputs because "type: true" is
2515-
// confusing, especially when we also have keys elsewhere named "type"
2516-
// that are type USRs.
2517-
printFlag(FD->isStatic(), Writer.isParsable() ? "static" : "type");
2517+
printFlag(FD->isStatic(), "static", DeclModifierColor);
25182518
}
25192519

25202520
void visitFuncDecl(FuncDecl *FD, Label label) {
@@ -5306,14 +5306,15 @@ class PrintConformance : public PrintBase {
53065306
// parsable (JSON) output because it is far too much information when it is
53075307
// rendered as part of every declref that contains such a conformance.
53085308
auto shouldPrintDetails =
5309-
visited.insert(conformance).second; // && !Writer.isParsable();
5309+
visited.insert(conformance).second && !Writer.isParsable();
53105310

53115311
auto printCommon = [&](StringRef kind) {
53125312
printHead(kind, ASTNodeColor, label);
53135313
printTypeField(conformance->getType(), Label::always("type"));
53145314
printReferencedDeclField(conformance->getProtocol(),
53155315
Label::always("protocol"));
5316-
printFlag(!shouldPrintDetails, "<details printed above>");
5316+
if (!Writer.isParsable())
5317+
printFlag(!shouldPrintDetails, "<details printed above>");
53175318
};
53185319

53195320
switch (conformance->getKind()) {

test/Frontend/dump-parse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ _ = { (v: MyEnum) in }
110110
// CHECK-LABEL: (struct_decl range=[{{.+}}] "SelfParam"
111111
struct SelfParam {
112112

113-
// CHECK-LABEL: (func_decl range=[{{.+}}] "createOptional()" type
113+
// CHECK-LABEL: (func_decl range=[{{.+}}] "createOptional()" static
114114
// CHECK-NEXT: (parameter "self")
115115
// CHECK-NEXT: (parameter_list range=[{{.+}}])
116116
// CHECK-NEXT: (result=type_optional

test/attr/ApplicationMain/attr_main_throws.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct MyBase {
77
}
88
}
99

10-
// CHECK-AST: (func_decl implicit "$main()" interface type="(MyBase.Type) -> () throws -> ()" access=internal type
10+
// CHECK-AST: (func_decl implicit "$main()" interface type="(MyBase.Type) -> () throws -> ()" access=internal static
1111
// CHECK-AST-NEXT: (parameter "self")
1212
// CHECK-AST-NEXT: (parameter_list)
1313
// CHECK-AST-NEXT: (brace_stmt implicit

0 commit comments

Comments
 (0)