diff --git a/include/llvm/Linker.h b/include/llvm/Linker.h index 4f37459eb40..67f6fc12c59 100644 --- a/include/llvm/Linker.h +++ b/include/llvm/Linker.h @@ -30,7 +30,7 @@ class Linker { PreserveSource = 1 // Preserve the source module. }; - Linker(Module *M); + Linker(Module *M, bool SuppressWarnings=false); ~Linker(); Module *getModule() const { return Composite; } @@ -52,6 +52,8 @@ class Linker { private: Module *Composite; SmallPtrSet IdentifiedStructTypes; + + bool SuppressWarnings; }; } // End llvm namespace diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index df9d9c98426..1bfc8284b81 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; diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 2b5dce461c1..11870fa7683 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -50,6 +50,10 @@ Verbose("v", cl::desc("Print information about actions taken")); static cl::opt DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden); +static cl::opt +SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"), + cl::init(false)); + // LoadFile - Read the specified bitcode file in and return it. This routine // searches the link path for the specified file to try to find it... // @@ -86,7 +90,7 @@ int main(int argc, char **argv) { return 1; } - Linker L(Composite.get()); + Linker L(Composite.get(), SuppressWarnings); for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) { OwningPtr M(LoadFile(argv[0], InputFilenames[i], Context)); if (M.get() == 0) {