diff options
-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)); |