raw_ostream: Add a has_colors() method.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 20 Jul 2012 18:29:41 +0000 (18:29 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 20 Jul 2012 18:29:41 +0000 (18:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160558 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/raw_ostream.h
lib/Support/raw_ostream.cpp

index 6c5d4787e0f5096dc1e510edaf0f20472dbbb87b..18bb31db76ea10dbf6ce463452f91ff81d92c8f3 100644 (file)
@@ -230,6 +230,9 @@ public:
   /// rather than being put on a pipe or stored in a file.
   virtual bool is_displayed() const { return false; }
 
+  /// This function determines if this stream is displayed and supports colors.
+  virtual bool has_colors() const { return is_displayed(); }
+
   //===--------------------------------------------------------------------===//
   // Subclass Interface
   //===--------------------------------------------------------------------===//
@@ -386,6 +389,8 @@ public:
 
   virtual bool is_displayed() const;
 
+  virtual bool has_colors() const;
+
   /// has_error - Return the value of the flag in this raw_fd_ostream indicating
   /// whether an output error has been encountered.
   /// This doesn't implicitly flush any pending output.  Also, it doesn't
index 0cd9716ac94c55666a212caba34cb91d278cab4c..fa69c2d3f538d796feb686b50b8b102d19ba770b 100644 (file)
@@ -651,6 +651,10 @@ bool raw_fd_ostream::is_displayed() const {
   return sys::Process::FileDescriptorIsDisplayed(FD);
 }
 
+bool raw_fd_ostream::has_colors() const {
+  return sys::Process::FileDescriptorHasColors(FD);
+}
+
 //===----------------------------------------------------------------------===//
 //  outs(), errs(), nulls()
 //===----------------------------------------------------------------------===//