Author: dougk Date: Tue Nov 17 11:41:23 2015 New Revision: 253350 URL: http://llvm.org/viewvc/llvm-project?rev=253350&view=rev Log: Add trivial utility to append -L arguments to linker step. NFC
Modified: cfe/trunk/include/clang/Driver/ToolChain.h cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/include/clang/Driver/ToolChain.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=253350&r1=253349&r2=253350&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/ToolChain.h (original) +++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Nov 17 11:41:23 2015 @@ -377,6 +377,10 @@ public: virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const; + /// AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option. + void AddFilePathLibArgs(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const; + /// AddCCKextLibArgs - Add the system specific linker arguments to use /// for kernel extensions (Darwin-specific). virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args, Modified: cfe/trunk/lib/Driver/ToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=253350&r1=253349&r2=253350&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChain.cpp (original) +++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Nov 17 11:41:23 2015 @@ -616,6 +616,12 @@ void ToolChain::AddCXXStdlibLibArgs(cons } } +void ToolChain::AddFilePathLibArgs(const ArgList &Args, + ArgStringList &CmdArgs) const { + for (const auto &LibPath : getFilePaths()) + CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath)); +} + void ToolChain::AddCCKextLibArgs(const ArgList &Args, ArgStringList &CmdArgs) const { CmdArgs.push_back("-lcc_kext"); Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253350&r1=253349&r2=253350&view=diff ============================================================================== --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Tue Nov 17 11:41:23 2015 @@ -6153,9 +6153,7 @@ constructHexagonLinkArgs(Compilation &C, //---------------------------------------------------------------------------- // Library Search Paths //---------------------------------------------------------------------------- - const ToolChain::path_list &LibPaths = ToolChain.getFilePaths(); - for (const auto &LibPath : LibPaths) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath)); + ToolChain.AddFilePathLibArgs(Args, CmdArgs); //---------------------------------------------------------------------------- // @@ -6525,9 +6523,7 @@ void cloudabi::Linker::ConstructJob(Comp } Args.AddAllArgs(CmdArgs, options::OPT_L); - const ToolChain::path_list &Paths = ToolChain.getFilePaths(); - for (const auto &Path : Paths) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); + ToolChain.AddFilePathLibArgs(Args, CmdArgs); Args.AddAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_e, options::OPT_s, options::OPT_t, options::OPT_Z_Flag, options::OPT_r}); @@ -7127,9 +7123,7 @@ void solaris::Linker::ConstructJob(Compi Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o"))); } - const ToolChain::path_list &Paths = getToolChain().getFilePaths(); - for (const auto &Path : Paths) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); + getToolChain().AddFilePathLibArgs(Args, CmdArgs); Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group, options::OPT_e, options::OPT_r}); @@ -7674,9 +7668,7 @@ void freebsd::Linker::ConstructJob(Compi } Args.AddAllArgs(CmdArgs, options::OPT_L); - const ToolChain::path_list &Paths = ToolChain.getFilePaths(); - for (const auto &Path : Paths) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); + ToolChain.AddFilePathLibArgs(Args, CmdArgs); Args.AddAllArgs(CmdArgs, options::OPT_T_Group); Args.AddAllArgs(CmdArgs, options::OPT_e); Args.AddAllArgs(CmdArgs, options::OPT_s); @@ -8567,10 +8559,7 @@ void gnutools::Linker::ConstructJob(Comp Args.AddAllArgs(CmdArgs, options::OPT_L); Args.AddAllArgs(CmdArgs, options::OPT_u); - const ToolChain::path_list &Paths = ToolChain.getFilePaths(); - - for (const auto &Path : Paths) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); + ToolChain.AddFilePathLibArgs(Args, CmdArgs); if (D.isUsingLTO()) AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin); @@ -8771,10 +8760,7 @@ void nacltools::Linker::ConstructJob(Com Args.AddAllArgs(CmdArgs, options::OPT_L); Args.AddAllArgs(CmdArgs, options::OPT_u); - const ToolChain::path_list &Paths = ToolChain.getFilePaths(); - - for (const auto &Path : Paths) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); + ToolChain.AddFilePathLibArgs(Args, CmdArgs); if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle)) CmdArgs.push_back("--no-demangle"); @@ -9539,10 +9525,7 @@ void MinGW::Linker::ConstructJob(Compila } Args.AddAllArgs(CmdArgs, options::OPT_L); - const ToolChain::path_list Paths = TC.getFilePaths(); - for (const auto &Path : Paths) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); - + TC.AddFilePathLibArgs(Args, CmdArgs); AddLinkerInputs(TC, Inputs, Args, CmdArgs); // TODO: Add ASan stuff here @@ -9822,11 +9805,7 @@ void CrossWindows::Linker::ConstructJob( } Args.AddAllArgs(CmdArgs, options::OPT_L); - - const auto &Paths = TC.getFilePaths(); - for (const auto &Path : Paths) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path)); - + TC.AddFilePathLibArgs(Args, CmdArgs); AddLinkerInputs(TC, Inputs, Args, CmdArgs); if (D.CCCIsCXX() && !Args.hasArg(options::OPT_nostdlib) && @@ -10222,12 +10201,7 @@ static void ConstructGoldLinkJob(const T } Args.AddAllArgs(CmdArgs, options::OPT_L); - - const ToolChain::path_list Paths = ToolChain.getFilePaths(); - for (ToolChain::path_list::const_iterator i = Paths.begin(), e = Paths.end(); - i != e; ++i) - CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + *i)); - + ToolChain.AddFilePathLibArgs(Args, CmdArgs); Args.AddAllArgs(CmdArgs, options::OPT_T_Group); Args.AddAllArgs(CmdArgs, options::OPT_e); Args.AddAllArgs(CmdArgs, options::OPT_s); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits