[cfe-commits] r81281 - in /cfe/trunk: include/clang/Basic/DiagnosticDriverKinds.td lib/Driver/Driver.cpp

Daniel Dunbar daniel at zuster.org
Tue Sep 8 16:37:30 PDT 2009


Author: ddunbar
Date: Tue Sep  8 18:37:30 2009
New Revision: 81281

URL: http://llvm.org/viewvc/llvm-project?rev=81281&view=rev
Log:
Validate arguments to -arch.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
    cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=81281&r1=81280&r2=81281&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Sep  8 18:37:30 2009
@@ -14,6 +14,8 @@
 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<

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=81281&r1=81280&r2=81281&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Sep  8 18:37:30 2009
@@ -601,6 +601,16 @@
     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));





More information about the cfe-commits mailing list