summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2014-02-20 22:19:24 +0000
committerEli Bendersky <eliben@google.com>2014-02-20 22:19:24 +0000
commit7da92ed8794185c1b101c42e9d9e809a94abfbcb (patch)
treeaa36326e92da80691f84dcc6f06ea430c460144c /llvm
parentc8130a74f498c5ca3d1d6276df392bae337cf221 (diff)
downloadbcm5719-llvm-7da92ed8794185c1b101c42e9d9e809a94abfbcb.tar.gz
bcm5719-llvm-7da92ed8794185c1b101c42e9d9e809a94abfbcb.zip
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. llvm-svn: 201819
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Linker.h4
-rw-r--r--llvm/lib/Linker/LinkModules.cpp25
-rw-r--r--llvm/tools/llvm-link/llvm-link.cpp6
3 files changed, 21 insertions, 14 deletions
diff --git a/llvm/include/llvm/Linker.h b/llvm/include/llvm/Linker.h
index 4f37459eb40..67f6fc12c59 100644
--- a/llvm/include/llvm/Linker.h
+++ b/llvm/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<StructType*, 32> IdentifiedStructTypes;
+
+ bool SuppressWarnings;
};
} // End llvm namespace
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index df9d9c98426..1bfc8284b81 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -27,10 +27,6 @@
using namespace llvm;
-static cl::opt<bool>
-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<Function*> 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/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index 2b5dce461c1..11870fa7683 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -50,6 +50,10 @@ Verbose("v", cl::desc("Print information about actions taken"));
static cl::opt<bool>
DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden);
+static cl::opt<bool>
+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<Module> M(LoadFile(argv[0], InputFilenames[i], Context));
if (M.get() == 0) {
OpenPOWER on IntegriCloud