]> granicus.if.org Git - clang/commitdiff
Move logic for selection -fmessage-length= to driver.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 4 Nov 2009 06:24:47 +0000 (06:24 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 4 Nov 2009 06:24:47 +0000 (06:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86013 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
tools/clang-cc/clang-cc.cpp

index aee9297efe38ef274031a7e224f8ae90778bed3a..04463be37feecb16e08d52f796558939d483ef36 100644 (file)
@@ -26,6 +26,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/System/Process.h"
 
 #include "InputInfo.h"
 #include "ToolChains.h"
@@ -839,13 +840,23 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back(A->getValue(Args));
   }
 
+  // Pass -fmessage-length=.
+  if (Arg *A = Args.getLastArg(options::OPT_fmessage_length_EQ)) {
+    A->render(Args, CmdArgs);
+  } else {
+    // If -fmessage-length=N was not specified, determine whether this is a
+    // terminal and, if so, implicitly define -fmessage-length appropriately.
+    unsigned N = llvm::sys::Process::StandardErrColumns();
+    CmdArgs.push_back("-fmessage-length");
+    CmdArgs.push_back(Args.MakeArgString(llvm::Twine(N)));
+  }
+
   // Forward -f options which we can pass directly.
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_ffreestanding);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fgnu_runtime);
   Args.AddLastArg(CmdArgs, options::OPT_flax_vector_conversions);
-  Args.AddLastArg(CmdArgs, options::OPT_fmessage_length_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_fms_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fnext_runtime);
   Args.AddLastArg(CmdArgs, options::OPT_fno_caret_diagnostics);
index 6b84c73af169f0a16236c2cad9eaa1018f1be3f6..c09f44b7384c30ab2cc344c19ad81dae60db3b0e 100644 (file)
@@ -2153,12 +2153,6 @@ int main(int argc, char **argv) {
   if (InputFilenames.empty())
     InputFilenames.push_back("-");
 
-  // If -fmessage-length=N was not specified, determine whether this
-  // is a terminal and, if so, implicitly define -fmessage-length
-  // appropriately.
-  if (MessageLength.getNumOccurrences() == 0)
-    MessageLength.setValue(llvm::sys::Process::StandardErrColumns());
-
   // Initialize the diagnostic options.
   DiagOpts.ShowColumn = !NoShowColumn;
   DiagOpts.ShowLocation = !NoShowLocation;