Skip to content

Commit 8df48e5

Browse files
committed
Address more reviewer feedback.
1 parent 87cabb0 commit 8df48e5

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
@@ -2064,7 +2064,21 @@ namespace {
20642064
printCommonPost(PD);
20652065
}
20662066

2067-
void printGenericParameters(GenericParamList *Params) {
2067+
void printGenericSignature(const GenericSignature &Sig, Label label) {
2068+
if (!Sig)
2069+
return;
2070+
2071+
printRecArbitrary([&](Label label) {
2072+
printHead("generic_signature", ASTNodeColor, label);
2073+
printList(Sig.getGenericParams(), [&](auto GP, Label label) {
2074+
printTypeField(GP, label);
2075+
}, Label::always("generic_params"));
2076+
printGenericRequirements(Sig.getRequirements());
2077+
printFoot();
2078+
}, label);
2079+
}
2080+
2081+
void printParsedGenericParams(GenericParamList *Params) {
20682082
if (!Params)
20692083
return;
20702084

@@ -2101,20 +2115,13 @@ namespace {
21012115
printCommon((Decl*)VD, Name, label, Color);
21022116

21032117
printDeclName(VD, Label::optional("name"));
2104-
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(VD)) {
2105-
printGenericParameters(AFD->getParsedGenericParams());
2106-
if (AFD->hasComputedGenericSignature())
2107-
printGenericRequirements(AFD->getGenericRequirements());
2108-
}
2109-
if (auto *GTD = dyn_cast<GenericTypeDecl>(VD)) {
2110-
printGenericParameters(GTD->getParsedGenericParams());
2111-
if (GTD->hasComputedGenericSignature())
2112-
printGenericRequirements(GTD->getGenericRequirements());
2113-
}
2114-
if (auto *MD = dyn_cast<MacroDecl>(VD)) {
2115-
printGenericParameters(MD->getParsedGenericParams());
2116-
if (MD->hasComputedGenericSignature())
2117-
printGenericRequirements(MD->getGenericRequirements());
2118+
if (auto *GC = VD->getAsGenericContext()) {
2119+
if (Writer.isParsable() && GC->hasComputedGenericSignature()) {
2120+
printGenericSignature(GC->getGenericSignature(),
2121+
Label::optional("generic_signature"));
2122+
} else {
2123+
printParsedGenericParams(GC->getParsedGenericParams());
2124+
}
21182125
}
21192126

21202127
if (VD->hasInterfaceType()) {
@@ -2277,11 +2284,7 @@ namespace {
22772284
}
22782285

22792286
void printStorageImpl(AbstractStorageDecl *D) {
2280-
// Use a different label for the parsable outputs because "type: true" is
2281-
// confusing, especially when we also have keys elsewhere named "type"
2282-
// that are type USRs.
2283-
printFlag(D->isStatic(), Writer.isParsable() ? "static" : "type",
2284-
DeclModifierColor);
2287+
printFlag(D->isStatic(), "static", DeclModifierColor);
22852288

22862289
if (D->hasInterfaceType()) {
22872290
auto impl = D->getImplInfo();
@@ -2519,10 +2522,7 @@ namespace {
25192522

25202523
void printCommonFD(FuncDecl *FD, const char *type, Label label) {
25212524
printCommonAFD(FD, type, label);
2522-
// Use a different label for the parsable outputs because "type: true" is
2523-
// confusing, especially when we also have keys elsewhere named "type"
2524-
// that are type USRs.
2525-
printFlag(FD->isStatic(), Writer.isParsable() ? "static" : "type");
2525+
printFlag(FD->isStatic(), "static", DeclModifierColor);
25262526
}
25272527

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

53215321
auto printCommon = [&](StringRef kind) {
53225322
printHead(kind, ASTNodeColor, label);
53235323
printTypeField(conformance->getType(), Label::always("type"));
53245324
printReferencedDeclField(conformance->getProtocol(),
53255325
Label::always("protocol"));
5326-
printFlag(!shouldPrintDetails, "<details printed above>");
5326+
if (!Writer.isParsable())
5327+
printFlag(!shouldPrintDetails, "<details printed above>");
53275328
};
53285329

53295330
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)