COFF: ensure that we handle bad arguments

The parameter to /debugtype is user provided and may be invalid.  Ensure
that we gracefully handle bad input.

llvm-svn: 294280
This commit is contained in:
Saleem Abdulrasool 2017-02-07 04:28:05 +00:00
parent 0acd6dd6ce
commit b6394287e2
2 changed files with 7 additions and 1 deletions

View File

@ -406,7 +406,8 @@ static unsigned parseDebugType(StringRef Arg) {
DebugTypes |= StringSwitch<unsigned>(Type.lower())
.Case("cv", static_cast<unsigned>(DebugType::CV))
.Case("pdata", static_cast<unsigned>(DebugType::PData))
.Case("fixup", static_cast<unsigned>(DebugType::Fixup));
.Case("fixup", static_cast<unsigned>(DebugType::Fixup))
.Default(0);
return DebugTypes;
}

View File

@ -0,0 +1,5 @@
# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
# RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
# RUN: /debugpdb %t1.obj %t2.obj