From: John Brawn Date: Wed, 23 Sep 2015 13:55:40 +0000 (+0000) Subject: Add -fplugin=name.so option to the driver X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9dcbcab85ccca71ccdfa924b6946a0475d93b636;p=clang Add -fplugin=name.so option to the driver This translates to -load name.so in the cc1 command. We can't name the driver option -load, as that means "link against oad", so instead we follow GCC's lead and name the option -fplugin. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@248378 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 8c15cef8ef..ebc6f3cb5e 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -949,6 +949,8 @@ def fpic : Flag<["-"], "fpic">, Group; def fno_pic : Flag<["-"], "fno-pic">, Group; def fpie : Flag<["-"], "fpie">, Group; def fno_pie : Flag<["-"], "fno-pie">, Group; +def fplugin_EQ : Joined<["-"], "fplugin=">, Group, Flags<[DriverOption]>, MetaVarName<"">, + HelpText<"Load the named plugin (dynamic shared object)">; def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group; def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group; def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index f4070217b4..7354421dad 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -5037,6 +5037,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Forward -fparse-all-comments to -cc1. Args.AddAllArgs(CmdArgs, options::OPT_fparse_all_comments); + // Turn -fplugin=name.so into -load name.so + for (const Arg *A : Args.filtered(options::OPT_fplugin_EQ)) { + CmdArgs.push_back("-load"); + CmdArgs.push_back(A->getValue()); + A->claim(); + } + // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option // parser. Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); diff --git a/test/Driver/fplugin.c b/test/Driver/fplugin.c new file mode 100644 index 0000000000..d0aaa9efe6 --- /dev/null +++ b/test/Driver/fplugin.c @@ -0,0 +1,7 @@ +// Check that all -fplugin arguments are converted to -load + +// RUN: %clang -c %s -fplugin=foo.so -### 2>&1 | FileCheck %s --check-prefix=CHECK1 +// RUN: %clang -c %s -fplugin=foo.so -fplugin=bar.so -### 2>&1 | FileCheck %s --check-prefix=CHECK2 + +// CHECK1: "-load" "foo.so" +// CHECK2: "-load" "foo.so" "-load" "bar.so"