[clang] [driver] Do not warn about unused plugin flags. (PR #88948)

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 22 02:32:18 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-driver

Author: Michael Kruse (Meinersbur)

<details>
<summary>Changes</summary>

Plugins are not loaded without the -cc1 phase. Do not report them when running on an assembly file or when linking. Many build tools add these options to all driver invocations, including LLVM's build system.

Fixes #<!-- -->88173

---
Full diff: https://github.com/llvm/llvm-project/pull/88948.diff


2 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+3-3) 
- (added) clang/test/Driver/clang-s-plugin.s (+5) 


``````````diff
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index e24626913add76..c1d85c527d437b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3630,14 +3630,14 @@ defm rwpi : BoolFOption<"rwpi",
           "Generate read-write position independent code (ARM only)">,
   NegFlag<SetFalse, [], [ClangOption, FlangOption, CC1Option]>>;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group<f_Group>,
-  Flags<[NoXarchOption]>, MetaVarName<"<dsopath>">,
+  Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"<dsopath>">,
   HelpText<"Load the named plugin (dynamic shared object)">;
 def fplugin_arg : Joined<["-"], "fplugin-arg-">,
-  MetaVarName<"<name>-<arg>">,
+  MetaVarName<"<name>-<arg>">, Flags<[NoArgumentUnused]>,
   HelpText<"Pass <arg> to plugin <name>">;
 def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
   Group<f_Group>, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-  MetaVarName<"<dsopath>">,
+  MetaVarName<"<dsopath>">, Flags<[NoArgumentUnused]>,
   HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">,
   MarshallingInfoStringVector<CodeGenOpts<"PassPlugins">>;
 defm tocdata : BoolOption<"m","tocdata",
diff --git a/clang/test/Driver/clang-s-plugin.s b/clang/test/Driver/clang-s-plugin.s
new file mode 100644
index 00000000000000..81169b7bc5bbc8
--- /dev/null
+++ b/clang/test/Driver/clang-s-plugin.s
@@ -0,0 +1,5 @@
+// RUN: %clang -### -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option -Werror %s 2>&1 | FileCheck %s
+
+// Plugins are only relevant for the -cc1 phase. No warning should be raised
+// when applied to assembly files. See GH #88173.
+// CHECK-NOT: argument unused during compilation

``````````

</details>


https://github.com/llvm/llvm-project/pull/88948


More information about the cfe-commits mailing list