From 6e31a49931b8b057868a64e89838e3c9b40f9198 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Mon, 6 May 2024 14:04:12 +0200 Subject: [PATCH] [driver] Do not warn about unused plugin flags. (#88948) 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 --- clang/include/clang/Driver/Options.td | 6 +++--- clang/test/Driver/plugin-driver-args.cpp | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 938d5358eeda6b..c9f7c4e5f718b4 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3663,14 +3663,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/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