r274119 - Use ArgList::hasFlag to check if -miamcu/-mno-iamcu is passed. NFC.

Andrey Turetskiy via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 29 03:57:17 PDT 2016


Author: aturetsk
Date: Wed Jun 29 05:57:17 2016
New Revision: 274119

URL: http://llvm.org/viewvc/llvm-project?rev=274119&view=rev
Log:
Use ArgList::hasFlag to check if -miamcu/-mno-iamcu is passed. NFC.

Differential Revision: http://reviews.llvm.org/D21641

Modified:
    cfe/trunk/lib/Driver/Driver.cpp
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=274119&r1=274118&r2=274119&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Jun 29 05:57:17 2016
@@ -280,9 +280,8 @@ DerivedArgList *Driver::TranslateInputAr
   }
 
   // Enforce -static if -miamcu is present.
-  if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu))
-    if (Ar->getOption().matches(options::OPT_miamcu))
-      DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
+  if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false))
+    DAL->AddFlagArg(0, Opts->getOption(options::OPT_static));
 
 // Add a default value of -mlinker-version=, if one was given and the user
 // didn't specify one.
@@ -376,24 +375,22 @@ static llvm::Triple computeTargetTriple(
   }
 
   // Handle -miamcu flag.
-  if (Arg *Ar = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) {
-    if (Ar->getOption().matches(options::OPT_miamcu)) {
-      if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
-        D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
-                                                         << Target.str();
-
-      if (A && !A->getOption().matches(options::OPT_m32))
-        D.Diag(diag::err_drv_argument_not_allowed_with)
-            << "-miamcu" << A->getBaseArg().getAsString(Args);
-
-      Target.setArch(llvm::Triple::x86);
-      Target.setArchName("i586");
-      Target.setEnvironment(llvm::Triple::UnknownEnvironment);
-      Target.setEnvironmentName("");
-      Target.setOS(llvm::Triple::ELFIAMCU);
-      Target.setVendor(llvm::Triple::UnknownVendor);
-      Target.setVendorName("intel");
-    }
+  if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) {
+    if (Target.get32BitArchVariant().getArch() != llvm::Triple::x86)
+      D.Diag(diag::err_drv_unsupported_opt_for_target) << "-miamcu"
+                                                       << Target.str();
+
+    if (A && !A->getOption().matches(options::OPT_m32))
+      D.Diag(diag::err_drv_argument_not_allowed_with)
+          << "-miamcu" << A->getBaseArg().getAsString(Args);
+
+    Target.setArch(llvm::Triple::x86);
+    Target.setArchName("i586");
+    Target.setEnvironment(llvm::Triple::UnknownEnvironment);
+    Target.setEnvironmentName("");
+    Target.setOS(llvm::Triple::ELFIAMCU);
+    Target.setVendor(llvm::Triple::UnknownVendor);
+    Target.setVendorName("intel");
   }
 
   return Target;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=274119&r1=274118&r2=274119&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jun 29 05:57:17 2016
@@ -2247,12 +2247,10 @@ void Clang::AddX86TargetArgs(const ArgLi
   }
 
   // Set flags to support MCU ABI.
-  if (Arg *A = Args.getLastArg(options::OPT_miamcu, options::OPT_mno_iamcu)) {
-    if (A->getOption().matches(options::OPT_miamcu)) {
-      CmdArgs.push_back("-mfloat-abi");
-      CmdArgs.push_back("soft");
-      CmdArgs.push_back("-mstack-alignment=4");
-    }
+  if (Args.hasFlag(options::OPT_miamcu, options::OPT_mno_iamcu, false)) {
+    CmdArgs.push_back("-mfloat-abi");
+    CmdArgs.push_back("soft");
+    CmdArgs.push_back("-mstack-alignment=4");
   }
 }
 




More information about the cfe-commits mailing list