@@ -371,9 +371,9 @@ static Type defaultGetTypeOfKeyPathComponent(KeyPathExpr *E, unsigned index) {
371
371
372
372
namespace {
373
373
class PrintBase {
374
- public:
375
374
raw_ostream &OS;
376
375
unsigned Indent;
376
+ public:
377
377
llvm::function_ref<Type(Expr *)> GetTypeOfExpr;
378
378
llvm::function_ref<Type(TypeRepr *)> GetTypeOfTypeRepr;
379
379
llvm::function_ref<Type(KeyPathExpr *E, unsigned index)>
@@ -388,6 +388,10 @@ class PrintBase {
388
388
GetTypeOfTypeRepr(getTypeOfTypeRepr),
389
389
GetTypeOfKeyPathComponent(getTypeOfKeyPathComponent) { }
390
390
391
+ bool hasNonStandardOutput () {
392
+ return &OS != &llvm::errs () && &OS != &llvm::dbgs ();
393
+ }
394
+
391
395
template <typename Fn>
392
396
void printRecRaw (Fn Body, StringRef label = " " ) {
393
397
Indent += 2 ;
@@ -869,7 +873,7 @@ class PrintBase {
869
873
void visitExtensionDecl (ExtensionDecl *ED, StringRef label) {
870
874
printCommon (ED, " extension_decl" , label, ExtensionColor);
871
875
printFlag (!ED->hasBeenBound (), " unbound" );
872
- printNameRaw ([&](raw_ostream &os ) {
876
+ printNameRaw ([&](raw_ostream &OS ) {
873
877
if (ED->hasBeenBound ())
874
878
ED->getExtendedType ().print (OS);
875
879
else
@@ -2031,7 +2035,6 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, StringRef>,
2031
2035
2032
2036
void visitOtherConstructorDeclRefExpr (OtherConstructorDeclRefExpr *E, StringRef label) {
2033
2037
printCommon (E, " other_constructor_ref_expr" , label);
2034
- PrintWithColorRAII (OS, DeclColor);
2035
2038
printDeclRefField (" decl" , E->getDeclRef ());
2036
2039
printFoot ();
2037
2040
}
@@ -2496,7 +2499,7 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, StringRef>,
2496
2499
2497
2500
// If we aren't printing to standard error or the debugger output stream,
2498
2501
// this client expects to see the computed discriminator. Compute it now.
2499
- if (&OS != & llvm::errs () && &OS != & llvm::dbgs ())
2502
+ if (hasNonStandardOutput ())
2500
2503
(void )E->getDiscriminator ();
2501
2504
2502
2505
printField (" discriminator" , E->getRawDiscriminator (), DiscriminatorColor);
@@ -2518,7 +2521,6 @@ class PrintExpr : public ExprVisitor<PrintExpr, void, StringRef>,
2518
2521
}
2519
2522
2520
2523
if (!E->getCaptureInfo ().isTrivial ()) {
2521
- OS << " " ;
2522
2524
printFieldRaw (" " , [&](raw_ostream &OS) {
2523
2525
E->getCaptureInfo ().print (OS);
2524
2526
}, CapturesColor);
0 commit comments