@@ -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
0 commit comments