From 55efe142a84b2aab6d0186c20a311c347a65f794 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 4 Nov 2009 06:24:47 +0000 Subject: [PATCH] Move logic for selection -fmessage-length= to driver. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86013 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 13 ++++++++++++- tools/clang-cc/clang-cc.cpp | 6 ------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index aee9297efe..04463be37f 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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); diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index 6b84c73af1..c09f44b738 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -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; -- 2.40.0