diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-09-08 23:37:30 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-09-08 23:37:30 +0000 |
commit | 36df2904354ac150500ec16238a1ec3cce4ba83e (patch) | |
tree | b17774074b14d8c0ed28aaebb8ba8fe51711e150 | |
parent | d7502d0a662b5c299125aba04245aefce67cbc22 (diff) |
Validate arguments to -arch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81281 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticDriverKinds.td | 2 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index 486bfb3c7e..a33fa0843e 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -14,6 +14,8 @@ def err_drv_unsupported_opt : Error<"unsupported option '%0'">; def err_drv_unknown_stdin_type : Error< "-E or -x required when input is from standard input">; def err_drv_unknown_language : Error<"language not recognized: '%0'">; +def err_drv_invalid_arch_name : Error< + "invalid arch name '%0'">; def err_drv_invalid_opt_with_multiple_archs : Error< "option '%0' cannot be used with multiple -arch options">; def err_drv_invalid_output_with_multiple_archs : Error< diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index f58c8829eb..59099a33e6 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -601,6 +601,16 @@ void Driver::BuildUniversalActions(const ArgList &Args, Arg *A = *it; if (A->getOption().getId() == options::OPT_arch) { + // Validate the option here; we don't save the type here because its + // particular spelling may participate in other driver choices. + llvm::Triple::ArchType Arch = + llvm::Triple::getArchTypeForDarwinArchName(A->getValue(Args)); + if (Arch == llvm::Triple::UnknownArch) { + Diag(clang::diag::err_drv_invalid_arch_name) + << A->getAsString(Args); + continue; + } + A->claim(); if (ArchNames.insert(A->getValue(Args))) Archs.push_back(A->getValue(Args)); |