forked from OSchip/llvm-project
[driver] Don't blindly accept all -g options.
rdar://10383444 llvm-svn: 143732
This commit is contained in:
parent
4a2eab0dac
commit
c2bf338d35
|
@ -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))
|
||||
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);
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Check to make sure clang is somewhat picky about -g options.
|
||||
// rdar://10383444
|
||||
|
||||
// RUN: %clang -### -c -g %s 2>&1 | FileCheck -check-prefix=G %s
|
||||
// RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G3 %s
|
||||
// RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s
|
||||
// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s
|
||||
//
|
||||
// G: "-cc1"
|
||||
// G: "-g"
|
||||
//
|
||||
// G3: "-cc1"
|
||||
// G3: "-g"
|
||||
//
|
||||
// GANY: "-cc1"
|
||||
// GANY-NOT: "-g"
|
||||
//
|
||||
// GFOO: "-cc1"
|
||||
// GFOO-NOT: "-g"
|
Loading…
Reference in New Issue