summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorDouglas Katzman <dougk@google.com>2016-01-06 01:37:57 +0000
committerDouglas Katzman <dougk@google.com>2016-01-06 01:37:57 +0000
commita2ef81fde5ef18d076ab7a997b370984ab9c170f (patch)
tree9c2ed691e5433df2a53b898c4eff15ae4277ad5f /clang/lib/Frontend/CompilerInvocation.cpp
parentd7009f31a180e295cfdeb47d134c834c441b44f1 (diff)
downloadbcm5719-llvm-a2ef81fde5ef18d076ab7a997b370984ab9c170f.tar.gz
bcm5719-llvm-a2ef81fde5ef18d076ab7a997b370984ab9c170f.zip
Avoid assert failure on some invalid cc1 options.
Addressing review comment in D13221. Differential Revision: http://reviews.llvm.org/D15882 llvm-svn: 256897
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d3870424b6b..621acca6f4e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -399,18 +399,29 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
}
if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) {
- Opts.setDebugInfo(
- llvm::StringSwitch<CodeGenOptions::DebugInfoKind>(A->getValue())
+ unsigned Val =
+ llvm::StringSwitch<unsigned>(A->getValue())
.Case("line-tables-only", CodeGenOptions::DebugLineTablesOnly)
.Case("limited", CodeGenOptions::LimitedDebugInfo)
- .Case("standalone", CodeGenOptions::FullDebugInfo));
+ .Case("standalone", CodeGenOptions::FullDebugInfo)
+ .Default(~0U);
+ if (Val == ~0U)
+ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+ << A->getValue();
+ else
+ Opts.setDebugInfo(static_cast<CodeGenOptions::DebugInfoKind>(Val));
}
if (Arg *A = Args.getLastArg(OPT_debugger_tuning_EQ)) {
- Opts.setDebuggerTuning(
- llvm::StringSwitch<CodeGenOptions::DebuggerKind>(A->getValue())
- .Case("gdb", CodeGenOptions::DebuggerKindGDB)
- .Case("lldb", CodeGenOptions::DebuggerKindLLDB)
- .Case("sce", CodeGenOptions::DebuggerKindSCE));
+ unsigned Val = llvm::StringSwitch<unsigned>(A->getValue())
+ .Case("gdb", CodeGenOptions::DebuggerKindGDB)
+ .Case("lldb", CodeGenOptions::DebuggerKindLLDB)
+ .Case("sce", CodeGenOptions::DebuggerKindSCE)
+ .Default(~0U);
+ if (Val == ~0U)
+ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+ << A->getValue();
+ else
+ Opts.setDebuggerTuning(static_cast<CodeGenOptions::DebuggerKind>(Val));
}
Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags);
Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);
OpenPOWER on IntegriCloud