Skip to content

Commit 2b79371

Browse files
committed
Force computation of discriminators when dumping for non-debugging purposes
Some testing mechanisms depend on having closure discriminators pre-computed when dumping the AST. When not dumping to either the standard error or debugger output streams, trigger computation of closure discriminators prior to dumping them.
1 parent 402ba14 commit 2b79371

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,12 @@ void swift::printContext(raw_ostream &os, DeclContext *dc) {
13881388
PrintWithColorRAII(os, DiscriminatorColor)
13891389
<< "autoclosure discriminator=";
13901390
}
1391+
1392+
// If we aren't printing to standard error or the debugger output stream,
1393+
// this client expects to see the computed discriminator. Compute it now.
1394+
if (&os != &llvm::errs() && &os != &llvm::dbgs())
1395+
(void)ACE->getDiscriminator();
1396+
13911397
PrintWithColorRAII(os, DiscriminatorColor) << ACE->getRawDiscriminator();
13921398
break;
13931399
}
@@ -2554,6 +2560,12 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
25542560

25552561
llvm::raw_ostream &printClosure(AbstractClosureExpr *E, char const *name) {
25562562
printCommon(E, name);
2563+
2564+
// If we aren't printing to standard error or the debugger output stream,
2565+
// this client expects to see the computed discriminator. Compute it now.
2566+
if (&OS != &llvm::errs() && &OS != &llvm::dbgs())
2567+
(void)E->getDiscriminator();
2568+
25572569
PrintWithColorRAII(OS, DiscriminatorColor)
25582570
<< " discriminator=" << E->getRawDiscriminator();
25592571

0 commit comments

Comments
 (0)