From f17f214145c8e3b7d57cc3e11e836b4b1bf5ccbb Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Thu, 20 Feb 2014 22:19:24 +0000 Subject: Set the SuppressWarnings option on tool level and propagate to the library. The SuppressWarnings flag, unfortunately, isn't very useful for custom tools that want to use the LLVM module linker. So I'm changing it to a parameter of the Linker, and the flag itself moves to the llvm-link tool. For the time being as SuppressWarnings is pretty much the only "option" it seems reasonable to propagate it to Linker objects. If we end up with more options in the future, some sort of "struct collecting options" may be a better idea. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201819 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Linker/LinkModules.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'lib/Linker') diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index df9d9c9842..1bfc8284b8 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -27,10 +27,6 @@ using namespace llvm; -static cl::opt -SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"), - cl::init(false)); - //===----------------------------------------------------------------------===// // TypeMap implementation. //===----------------------------------------------------------------------===// @@ -408,15 +404,18 @@ namespace { // Vector of functions to lazily link in. std::vector LazilyLinkFunctions; + + bool SuppressWarnings; public: std::string ErrorMsg; - - ModuleLinker(Module *dstM, TypeSet &Set, Module *srcM, unsigned mode) - : DstM(dstM), SrcM(srcM), TypeMap(Set), - ValMaterializer(TypeMap, DstM, LazilyLinkFunctions), - Mode(mode) { } - + + ModuleLinker(Module *dstM, TypeSet &Set, Module *srcM, unsigned mode, + bool SuppressWarnings=false) + : DstM(dstM), SrcM(srcM), TypeMap(Set), + ValMaterializer(TypeMap, DstM, LazilyLinkFunctions), Mode(mode), + SuppressWarnings(SuppressWarnings) {} + bool run(); private: @@ -1354,7 +1353,8 @@ bool ModuleLinker::run() { return false; } -Linker::Linker(Module *M) : Composite(M) { +Linker::Linker(Module *M, bool SuppressWarnings) + : Composite(M), SuppressWarnings(SuppressWarnings) { TypeFinder StructTypes; StructTypes.run(*M, true); IdentifiedStructTypes.insert(StructTypes.begin(), StructTypes.end()); @@ -1369,7 +1369,8 @@ void Linker::deleteModule() { } bool Linker::linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg) { - ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src, Mode); + ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src, Mode, + SuppressWarnings); if (TheLinker.run()) { if (ErrorMsg) *ErrorMsg = TheLinker.ErrorMsg; -- cgit v1.2.3