llvm.org GIT mirror llvm / f17f214
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 Eli Bendersky 5 years ago
3 changed file(s) with 21 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
2929 PreserveSource = 1 // Preserve the source module.
3030 };
3131
32 Linker(Module *M);
32 Linker(Module *M, bool SuppressWarnings=false);
3333 ~Linker();
3434
3535 Module *getModule() const { return Composite; }
5151 private:
5252 Module *Composite;
5353 SmallPtrSet IdentifiedStructTypes;
54
55 bool SuppressWarnings;
5456 };
5557
5658 } // End llvm namespace
2525 #include
2626 using namespace llvm;
2727
28
29 static cl::opt
30 SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"),
31 cl::init(false));
3228
3329 //===----------------------------------------------------------------------===//
3430 // TypeMap implementation.
407403
408404 // Vector of functions to lazily link in.
409405 std::vector LazilyLinkFunctions;
406
407 bool SuppressWarnings;
410408
411409 public:
412410 std::string ErrorMsg;
413
414 ModuleLinker(Module *dstM, TypeSet &Set, Module *srcM, unsigned mode)
415 : DstM(dstM), SrcM(srcM), TypeMap(Set),
416 ValMaterializer(TypeMap, DstM, LazilyLinkFunctions),
417 Mode(mode) { }
418
411
412 ModuleLinker(Module *dstM, TypeSet &Set, Module *srcM, unsigned mode,
413 bool SuppressWarnings=false)
414 : DstM(dstM), SrcM(srcM), TypeMap(Set),
415 ValMaterializer(TypeMap, DstM, LazilyLinkFunctions), Mode(mode),
416 SuppressWarnings(SuppressWarnings) {}
417
419418 bool run();
420419
421420 private:
13531352 return false;
13541353 }
13551354
1356 Linker::Linker(Module *M) : Composite(M) {
1355 Linker::Linker(Module *M, bool SuppressWarnings)
1356 : Composite(M), SuppressWarnings(SuppressWarnings) {
13571357 TypeFinder StructTypes;
13581358 StructTypes.run(*M, true);
13591359 IdentifiedStructTypes.insert(StructTypes.begin(), StructTypes.end());
13681368 }
13691369
13701370 bool Linker::linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg) {
1371 ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src, Mode);
1371 ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src, Mode,
1372 SuppressWarnings);
13721373 if (TheLinker.run()) {
13731374 if (ErrorMsg)
13741375 *ErrorMsg = TheLinker.ErrorMsg;
4949 static cl::opt
5050 DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden);
5151
52 static cl::opt
53 SuppressWarnings("suppress-warnings", cl::desc("Suppress all linking warnings"),
54 cl::init(false));
55
5256 // LoadFile - Read the specified bitcode file in and return it. This routine
5357 // searches the link path for the specified file to try to find it...
5458 //
8589 return 1;
8690 }
8791
88 Linker L(Composite.get());
92 Linker L(Composite.get(), SuppressWarnings);
8993 for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
9094 OwningPtr M(LoadFile(argv[0], InputFilenames[i], Context));
9195 if (M.get() == 0) {