Skip to content

Commit f861cfc

Browse files
authored
Merge pull request #81351 from hamishknight/disk-golf
2 parents cf4de4a + 398efdc commit f861cfc

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,6 @@ namespace {
805805
virtual void printSourceRange(const SourceRange R, const ASTContext *Ctx,
806806
Label label) = 0;
807807

808-
virtual bool hasNonStandardOutput() const = 0;
809-
810808
/// Indicates whether the output format is meant to be parsable. Parsable
811809
/// output should use structure rather than stringification to convey
812810
/// detailed information, and generally provides more information than the
@@ -900,10 +898,6 @@ namespace {
900898
}, label, RangeColor);
901899
}
902900

903-
bool hasNonStandardOutput() const override {
904-
return &OS != &llvm::errs() && &OS != &llvm::dbgs();
905-
}
906-
907901
bool isParsable() const override { return false; }
908902
};
909903

@@ -1014,8 +1008,6 @@ namespace {
10141008
OS.attributeEnd();
10151009
}
10161010

1017-
bool hasNonStandardOutput() const override { return true; }
1018-
10191011
bool isParsable() const override { return true; }
10201012
};
10211013

@@ -1046,10 +1038,6 @@ namespace {
10461038
GetTypeOfExpr(getTypeOfExpr), GetTypeOfTypeRepr(getTypeOfTypeRepr),
10471039
GetTypeOfKeyPathComponent(getTypeOfKeyPathComponent) {}
10481040

1049-
bool hasNonStandardOutput() {
1050-
return Writer.hasNonStandardOutput();
1051-
}
1052-
10531041
bool isTypeChecked() const {
10541042
return MemberLoading == ASTDumpMemberLoading::TypeChecked;
10551043
}
@@ -3015,11 +3003,6 @@ void swift::printContext(raw_ostream &os, DeclContext *dc) {
30153003
<< "autoclosure discriminator=";
30163004
}
30173005

3018-
// If we aren't printing to standard error or the debugger output stream,
3019-
// this client expects to see the computed discriminator. Compute it now.
3020-
if (&os != &llvm::errs() && &os != &llvm::dbgs())
3021-
(void)ACE->getDiscriminator();
3022-
30233006
PrintWithColorRAII(os, DiscriminatorColor) << ACE->getRawDiscriminator();
30243007
break;
30253008
}
@@ -4094,16 +4077,15 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, Label>,
40944077
printFoot();
40954078
}
40964079

4097-
void printClosure(AbstractClosureExpr *E, char const *name,
4098-
Label label) {
4080+
void printClosure(AbstractClosureExpr *E, char const *name, Label label) {
40994081
printCommon(E, name, label);
41004082

4101-
// If we aren't printing to standard error or the debugger output stream,
4102-
// this client expects to see the computed discriminator. Compute it now.
4103-
if (hasNonStandardOutput())
4104-
(void)E->getDiscriminator();
4083+
// If we're dumping the type-checked AST, compute the discriminator if
4084+
// needed. Otherwise, print the cached discriminator.
4085+
auto discriminator = isTypeChecked() ? E->getDiscriminator()
4086+
: E->getRawDiscriminator();
41054087

4106-
printField(E->getRawDiscriminator(), Label::always("discriminator"),
4088+
printField(discriminator, Label::always("discriminator"),
41074089
DiscriminatorColor);
41084090
printIsolation(E->getActorIsolation());
41094091

test/IDE/range_info_basics.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func testPropertyWrapper() {
371371
// CHECK13-NEXT: b = b.bigEndian.bigEndian.byteSwapped
372372
// CHECK13-NEXT: print(b + c)</Content>
373373
// CHECK13-NEXT: <Type>Void</Type>
374-
// CHECK13-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator=0</Context>
374+
// CHECK13-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator={{[0-9]+}}</Context>
375375
// CHECK13-NEXT: <Declared>a</Declared><OutscopeReference>false</OutscopeReference>
376376
// CHECK13-NEXT: <Declared>b</Declared><OutscopeReference>false</OutscopeReference>
377377
// CHECK13-NEXT: <Declared>c</Declared><OutscopeReference>false</OutscopeReference>
@@ -396,7 +396,7 @@ func testPropertyWrapper() {
396396
// CHECK14-NEXT: return 1
397397
// CHECK14-NEXT: }()</Content>
398398
// CHECK14-NEXT: <Type>Int</Type>
399-
// CHECK14-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator=0</Context>
399+
// CHECK14-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator={{[0-9]+}}</Context>
400400
// CHECK14-NEXT: <Declared>a</Declared><OutscopeReference>false</OutscopeReference>
401401
// CHECK14-NEXT: <Declared>b</Declared><OutscopeReference>false</OutscopeReference>
402402
// CHECK14-NEXT: <Declared>c</Declared><OutscopeReference>false</OutscopeReference>
@@ -418,7 +418,7 @@ func testPropertyWrapper() {
418418
// CHECK15-NEXT: let c = a.byteSwapped
419419
// CHECK15-NEXT: b = b.bigEndian.bigEndian.byteSwapped</Content>
420420
// CHECK15-NEXT: <Type>Void</Type>
421-
// CHECK15-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator=0.explicit closure discriminator=0</Context>
421+
// CHECK15-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator={{[0-9]+}}.explicit closure discriminator={{[0-9]+}}</Context>
422422
// CHECK15-NEXT: <Declared>a</Declared><OutscopeReference>false</OutscopeReference>
423423
// CHECK15-NEXT: <Declared>b</Declared><OutscopeReference>true</OutscopeReference>
424424
// CHECK15-NEXT: <Declared>c</Declared><OutscopeReference>true</OutscopeReference>
@@ -435,7 +435,7 @@ func testPropertyWrapper() {
435435
// CHECK16-NEXT: print(b + c)
436436
// CHECK16-NEXT: return 1</Content>
437437
// CHECK16-NEXT: <Type>Int</Type>
438-
// CHECK16-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator=0.explicit closure discriminator=0</Context>
438+
// CHECK16-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator={{[0-9]+}}.explicit closure discriminator={{[0-9]+}}</Context>
439439
// CHECK16-NEXT: <Declared>a</Declared><OutscopeReference>false</OutscopeReference>
440440
// CHECK16-NEXT: <Declared>b</Declared><OutscopeReference>false</OutscopeReference>
441441
// CHECK16-NEXT: <Declared>c</Declared><OutscopeReference>false</OutscopeReference>
@@ -448,7 +448,7 @@ func testPropertyWrapper() {
448448
// CHECK17: <Kind>SingleExpression</Kind>
449449
// CHECK17-NEXT: <Content>print(b + c)</Content>
450450
// CHECK17-NEXT: <Type>()</Type>
451-
// CHECK17-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator=0.explicit closure discriminator=0</Context>
451+
// CHECK17-NEXT: <Context>swift_ide_test.(file).foo6().explicit closure discriminator={{[0-9]+}}.explicit closure discriminator={{[0-9]+}}</Context>
452452
// CHECK17-NEXT: <Referenced>b</Referenced><Type>Int</Type>
453453
// CHECK17-NEXT: <Referenced>c</Referenced><Type>Int</Type>
454454
// CHECK17-NEXT: <ASTNodes>1</ASTNodes>

0 commit comments

Comments
 (0)