diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-11-04 19:28:44 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-11-04 19:28:44 +0000 |
commit | 2875bda1505bce995f745002affb20862765ed04 (patch) | |
tree | 61e969a564d98dd0712efa47d6db66d7c61af204 /lib/Driver/Tools.cpp | |
parent | 03ea52f9f0f6fc796ecae5b568a7be489438269b (diff) |
[driver] Don't blindly accept all -g options.
rdar://10383444
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r-- | lib/Driver/Tools.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 4f84d0a0dd..8c0382fbf3 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1455,8 +1455,24 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // wrong. Args.ClaimAllArgs(options::OPT_g_Group); if (Arg *A = Args.getLastArg(options::OPT_g_Group)) - if (!A->getOption().matches(options::OPT_g0)) - CmdArgs.push_back("-g"); + if (!A->getOption().matches(options::OPT_g0)) { + StringRef ArgString = A->getAsString(Args); + bool Valid_g = llvm::StringSwitch<bool>(ArgString) + .Case("-g", true) + .Case("-g3", true) + .Case("-gdwarf-2", true) + .Case("-gstabs", true) + .Case("-gstabs+", true) + .Case("-gstabs1", true) + .Case("-gstabs2", true) + .Case("-gfull", true) + .Case("-gused", true) + .Default(false); + if (Valid_g) + CmdArgs.push_back("-g"); + else + D.Diag(diag::warn_drv_clang_unsupported) << ArgString; + } Args.AddAllArgs(CmdArgs, options::OPT_ffunction_sections); Args.AddAllArgs(CmdArgs, options::OPT_fdata_sections); |