If stderr isn't a terminal, don't try to guess the terminal width or
look at COLUMNS.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71120 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 3282c19..f71be5d 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -1895,6 +1895,10 @@
 /// \returns the width of the terminal (in characters), if there is a
 /// terminal. If there is no terminal, returns 0.
 static unsigned getTerminalWidth() {
+  // Is this a terminal? If not, don't wrap by default.
+  if (!llvm::sys::Process::StandardErrIsDisplayed())
+    return 0;
+
   // If COLUMNS is defined in the environment, wrap to that many columns.
   if (const char *ColumnsStr = std::getenv("COLUMNS")) {
     int Columns = atoi(ColumnsStr);
@@ -1902,10 +1906,6 @@
       return Columns;
   }
 
-  // Is this a terminal? If not, don't wrap by default.
-  if (!llvm::sys::Process::StandardErrIsDisplayed())
-    return 0;
-
 #if HAVE_SYS_TYPES_H
   // Try to determine the width of the terminal.
   struct winsize ws;