From d2cd62082b6967215e6fb7eb975377a01052b79a Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 16 Apr 2024 19:50:35 +0200 Subject: [PATCH 1/2] Do not warn about unused plugin flags. Plugins are not loaded without the -cc1 phase. Do not report them when running on a assembly file or when linking. Many build tools add these options to all driver invocations. See GH #88173. --- clang/include/clang/Driver/Options.td | 6 +++--- clang/test/Driver/clang-s-plugin.s | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 clang/test/Driver/clang-s-plugin.s diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 086aedefc11878..73ad01f2be8861 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3645,14 +3645,14 @@ defm rwpi : BoolFOption<"rwpi", "Generate read-write position independent code (ARM only)">, NegFlag>; def fplugin_EQ : Joined<["-"], "fplugin=">, Group, - Flags<[NoXarchOption]>, MetaVarName<"">, + Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"">, HelpText<"Load the named plugin (dynamic shared object)">; def fplugin_arg : Joined<["-"], "fplugin-arg-">, - MetaVarName<"-">, + MetaVarName<"-">, Flags<[NoArgumentUnused]>, HelpText<"Pass to plugin ">; def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">, Group, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, - MetaVarName<"">, + MetaVarName<"">, Flags<[NoArgumentUnused]>, HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">, MarshallingInfoStringVector>; 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 From 6e22e57300eba3ba8506c056c091d19d4c249bc5 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 30 Apr 2024 14:56:57 +0200 Subject: [PATCH 2/2] Address reviewer comment --- clang/test/Driver/clang-s-plugin.s | 5 ----- clang/test/Driver/plugin-driver-args.cpp | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 clang/test/Driver/clang-s-plugin.s diff --git a/clang/test/Driver/clang-s-plugin.s b/clang/test/Driver/clang-s-plugin.s deleted file mode 100644 index 81169b7bc5bbc8..00000000000000 --- a/clang/test/Driver/clang-s-plugin.s +++ /dev/null @@ -1,5 +0,0 @@ -// 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 diff --git a/clang/test/Driver/plugin-driver-args.cpp b/clang/test/Driver/plugin-driver-args.cpp index d6475b4b3d733a..6f0e6e2ba75251 100644 --- a/clang/test/Driver/plugin-driver-args.cpp +++ b/clang/test/Driver/plugin-driver-args.cpp @@ -20,3 +20,8 @@ // RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fplugin-arg-testname- -fsyntax-only %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PLUGIN-ARG2 // CHECK-NO-PLUGIN-ARG2: missing plugin argument for plugin testname in -fplugin-arg-testname- + +// Plugins are only relevant for the -cc1 phase. No warning should be raised +// when only using the assembler. See GH #88173. +// RUN: %clang -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option -Werror -x assembler %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PLUGIN-ASM +// CHECK-PLUGIN-ASM-NOT: argument unused during compilation