[PATCH] D134671: [Driver] Prevent Mips specific code from claiming -mabi argument on other targets.

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 26 13:25:53 PDT 2022


craig.topper created this revision.
craig.topper added reviewers: aaron.ballman, erichkeane.
Herald added subscribers: StephenFan, atanasyan, arichardson, sdardis.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

Fixes PR57976.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134671

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/mabi.c


Index: clang/test/Driver/mabi.c
===================================================================
--- /dev/null
+++ clang/test/Driver/mabi.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target i386-unknown-linux -mabi=ms -S %s -### 2>&1 | FileCheck --check-prefix=CHECK %s
+
+int f() {
+  // CHECK: warning: argument unused during compilation: '-mabi=ms'
+  return 0;
+}
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -634,8 +634,9 @@
 
   // If target is MIPS adjust the target triple
   // accordingly to provided ABI name.
-  A = Args.getLastArg(options::OPT_mabi_EQ);
+  A = Args.getLastArgNoClaim(options::OPT_mabi_EQ);
   if (A && Target.isMIPS()) {
+    A->claim();
     StringRef ABIName = A->getValue();
     if (ABIName == "32") {
       Target = Target.get32BitArchVariant();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134671.463006.patch
Type: text/x-patch
Size: 900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220926/36dba893/attachment.bin>


More information about the cfe-commits mailing list