From 72a6090dc4fc855b59cfd566b24d7f3e49ccde3b Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 26 Apr 2009 01:10:38 +0000 Subject: [PATCH] Driver: Add -std-default= option. - This can be used to supply a default value for -std=; the idea is that this can be used in conjunction with CCC_ADD_ARGS or QA_OVERRIDE_GCC3_OPTIONS to change the default without having to modify the build system. llvm-svn: 70102 --- clang/include/clang/Driver/Options.def | 3 +++ clang/lib/Driver/Tools.cpp | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.def b/clang/include/clang/Driver/Options.def index b4dc5528f114..71ed7293ca55 100644 --- a/clang/include/clang/Driver/Options.def +++ b/clang/include/clang/Driver/Options.def @@ -354,6 +354,7 @@ OPTION("-fasm-blocks", fasm_blocks, Flag, clang_ignored_f_Group, INVALID, "", 0, OPTION("-fastcp", fastcp, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fastf", fastf, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fast", fast, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fasynchronous-unwind-tables", fasynchronous_unwind_tables, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fblocks", fblocks, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fbootclasspath=", fbootclasspath_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) OPTION("-fbuiltin", fbuiltin, Flag, f_Group, INVALID, "", 0, 0, 0) @@ -392,6 +393,7 @@ OPTION("-fmudflapth", fmudflapth, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fmudflap", fmudflap, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fnested-functions", fnested_functions, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fnext-runtime", fnext_runtime, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-asynchronous-unwind-tables", fno_asynchronous_unwind_tables, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-blocks", fno_blocks, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-builtin", fno_builtin, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-caret-diagnostics", fno_caret_diagnostics, Flag, f_Group, INVALID, "", 0, 0, 0) @@ -581,6 +583,7 @@ OPTION("-specs=", specs_EQ, Joined, INVALID, INVALID, "", 0, 0, 0) OPTION("-specs", specs, Separate, INVALID, INVALID, "u", 0, 0, 0) OPTION("-static-libgcc", static_libgcc, Flag, INVALID, INVALID, "", 0, 0, 0) OPTION("-static", static, Flag, INVALID, INVALID, "q", 0, 0, 0) +OPTION("-std-default=", std_default_EQ, Joined, INVALID, INVALID, "", 0, 0, 0) OPTION("-std=", std_EQ, Joined, INVALID, INVALID, "", 0, 0, 0) OPTION("-sub_library", sub__library, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) OPTION("-sub_umbrella", sub__umbrella, JoinedOrSeparate, INVALID, INVALID, "", 0, 0, 0) diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index e180543d5310..d298a22d1ab2 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -438,8 +438,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (Arg *A = Args.getLastArg(options::OPT_trigraphs)) if (A->getIndex() > Std->getIndex()) A->render(Args, CmdArgs); - } else + } else { + // Honor -std-default. + Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, + "-std=", /*Joined=*/true); Args.AddLastArg(CmdArgs, options::OPT_trigraphs); + } if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_)) { CmdArgs.push_back("-ftemplate-depth"); @@ -825,6 +829,12 @@ void darwin::CC1::AddCC1OptionsArgs(const ArgList &Args, ArgStringList &CmdArgs, Args.AddLastArg(CmdArgs, options::OPT_w); Args.AddAllArgs(CmdArgs, options::OPT_std_EQ, options::OPT_ansi, options::OPT_trigraphs); + if (!Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) { + // Honor -std-default. + Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, + "-std=", /*Joined=*/true); + } + if (Args.hasArg(options::OPT_v)) CmdArgs.push_back("-version"); if (Args.hasArg(options::OPT_pg)) @@ -880,6 +890,11 @@ void darwin::CC1::AddCPPOptionsArgs(const ArgList &Args, ArgStringList &CmdArgs, Args.AddAllArgs(CmdArgs, options::OPT_m_Group); Args.AddAllArgs(CmdArgs, options::OPT_std_EQ, options::OPT_ansi, options::OPT_trigraphs); + if (!Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) { + // Honor -std-default. + Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, + "-std=", /*Joined=*/true); + } Args.AddAllArgs(CmdArgs, options::OPT_W_Group, options::OPT_pedantic_Group); Args.AddLastArg(CmdArgs, options::OPT_w);