<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I think I've fixed the issue. (a microsoft style __in on a parameter to <span class="Apple-style-span" style="font-size: 13px; ">GetConsoleTextAttribute)</span></div><br><div><div>On Apr 16, 2012, at 4:00 AM, Argyrios Kyrtzidis wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Apr 16, 2012, at 12:51 AM, Chandler Carruth wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Mon, Apr 16, 2012 at 9:07 AM, Argyrios Kyrtzidis <span dir="ltr"><<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
Author: akirtzidis<br>
Date: Mon Apr 16 02:07:38 2012<br>
New Revision: 154800<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=154800&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=154800&view=rev</a><br>
Log:<br>
Add reverseColor to raw_ostream.<br>
<br>
To be used in printing unprintable source in clang diagnostics.<br>
Patch by Seth Cantrell!<br></blockquote><div><br></div><div>Ugh, this broke windows builders:</div><div><br></div><div><a href="http://bb.pgr.jp/builders/clang-i686-msys/builds/729/steps/compile/logs/stdio">http://bb.pgr.jp/builders/clang-i686-msys/builds/729/steps/compile/logs/stdio</a></div></div></blockquote><div><br></div><div>Reverted.</div><br><blockquote type="cite"><div class="gmail_quote">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    llvm/trunk/include/llvm/Support/Process.h<br>
    llvm/trunk/include/llvm/Support/raw_ostream.h<br>
    llvm/trunk/lib/Support/Unix/Process.inc<br>
    llvm/trunk/lib/Support/Windows/Process.inc<br>
    llvm/trunk/lib/Support/raw_ostream.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Support/Process.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Process.h?rev=154800&r1=154799&r2=154800&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Process.h?rev=154800&r1=154799&r2=154800&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm/Support/Process.h (original)<br>
+++ llvm/trunk/include/llvm/Support/Process.h Mon Apr 16 02:07:38 2012<br>
@@ -136,6 +136,10 @@<br>
       /// Same as OutputColor, but only enables the bold attribute.<br>
       static const char *OutputBold(bool bg);<br>
<br>
+      /// This function returns the escape sequence to reverse forground and<br>
+      /// background colors.<br>
+      static const char *OutputReverse();<br>
+<br>
       /// Resets the terminals colors, or returns an escape sequence to do so.<br>
       static const char *ResetColor();<br>
     /// @}<br>
<br>
Modified: llvm/trunk/include/llvm/Support/raw_ostream.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=154800&r1=154799&r2=154800&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=154800&r1=154799&r2=154800&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)<br>
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Mon Apr 16 02:07:38 2012<br>
@@ -222,6 +222,9 @@<br>
   /// outputting colored text, or before program exit.<br>
   virtual raw_ostream &resetColor() { return *this; }<br>
<br>
+  /// Reverses the forground and background colors.<br>
+  virtual raw_ostream &reverseColor() { return *this; }<br>
+<br>
   /// This function determines if this stream is connected to a "tty" or<br>
   /// "console" window. That is, the output would be displayed to the user<br>
   /// rather than being put on a pipe or stored in a file.<br>
@@ -379,6 +382,8 @@<br>
                                    bool bg=false);<br>
   virtual raw_ostream &resetColor();<br>
<br>
+  virtual raw_ostream &reverseColor();<br>
+<br>
   virtual bool is_displayed() const;<br>
<br>
   /// has_error - Return the value of the flag in this raw_fd_ostream indicating<br>
<br>
Modified: llvm/trunk/lib/Support/Unix/Process.inc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Process.inc?rev=154800&r1=154799&r2=154800&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Process.inc?rev=154800&r1=154799&r2=154800&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/Unix/Process.inc (original)<br>
+++ llvm/trunk/lib/Support/Unix/Process.inc Mon Apr 16 02:07:38 2012<br>
@@ -290,6 +290,10 @@<br>
   return "\033[1m";<br>
 }<br>
<br>
+const char *Process::OutputReverse() {<br>
+  return "\033[7m";<br>
+}<br>
+<br>
 const char *Process::ResetColor() {<br>
   return "\033[0m";<br>
 }<br>
<br>
Modified: llvm/trunk/lib/Support/Windows/Process.inc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Process.inc?rev=154800&r1=154799&r2=154800&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Process.inc?rev=154800&r1=154799&r2=154800&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/Windows/Process.inc (original)<br>
+++ llvm/trunk/lib/Support/Windows/Process.inc Mon Apr 16 02:07:38 2012<br>
@@ -215,6 +215,39 @@<br>
   return 0;<br>
 }<br>
<br>
+WORD GetConsoleTextAttribute(__in HANDLE hConsoleOutput)<br>
+{<br>
+  CONSOLE_SCREEN_BUFFER_INFO info;<br>
+  GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),&info);<br>
+  return info.wAttributes;<br>
+}<br>
+<br>
+const char *Process::OutputReverse() {<br>
+  const WORD attributes<br>
+   = GetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE));<br>
+<br>
+  const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN |<br>
+    FOREGROUND_RED | FOREGROUND_INTENSITY;<br>
+  const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN |<br>
+    BACKGROUND_RED | BACKGROUND_INTENSITY;<br>
+  const WORD color_mask = foreground_mask | background_mask;<br>
+<br>
+  WORD new_attributes =<br>
+    ((attributes & FOREGROUND_BLUE     )?BACKGROUND_BLUE     :0) |<br>
+    ((attributes & FOREGROUND_GREEN    )?BACKGROUND_GREEN    :0) |<br>
+    ((attributes & FOREGROUND_RED      )?BACKGROUND_RED      :0) |<br>
+    ((attributes & FOREGROUND_INTENSITY)?BACKGROUND_INTENSITY:0) |<br>
+    ((attributes & BACKGROUND_BLUE     )?FOREGROUND_BLUE     :0) |<br>
+    ((attributes & BACKGROUND_GREEN    )?FOREGROUND_GREEN    :0) |<br>
+    ((attributes & BACKGROUND_RED      )?FOREGROUND_RED      :0) |<br>
+    ((attributes & BACKGROUND_INTENSITY)?FOREGROUND_INTENSITY:0) |<br>
+    0;<br>
+  new_attributes = (attributes & ~color_mask) | (new_attributes & color_mask);<br>
+<br>
+  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),new_attributes);<br>
+  return 0;<br>
+}<br>
+<br>
 const char *Process::ResetColor() {<br>
   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColors());<br>
   return 0;<br>
<br>
Modified: llvm/trunk/lib/Support/raw_ostream.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=154800&r1=154799&r2=154800&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=154800&r1=154799&r2=154800&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)<br>
+++ llvm/trunk/lib/Support/raw_ostream.cpp Mon Apr 16 02:07:38 2012<br>
@@ -633,6 +633,19 @@<br>
   return *this;<br>
 }<br>
<br>
+raw_ostream &raw_fd_ostream::reverseColor() {<br>
+  if (sys::Process::ColorNeedsFlush())<br>
+    flush();<br>
+  const char *colorcode = sys::Process::OutputReverse();<br>
+  if (colorcode) {<br>
+    size_t len = strlen(colorcode);<br>
+    write(colorcode, len);<br>
+    // don't account colors towards output characters<br>
+    pos -= len;<br>
+  }<br>
+  return *this;<br>
+}<br>
+<br>
 bool raw_fd_ostream::is_displayed() const {<br>
   return sys::Process::FileDescriptorIsDisplayed(FD);<br>
 }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br>
</blockquote></div><br></div></blockquote></div></body></html>