freebsd-dev/contrib/llvm/lib/Linker/Linker.cpp

71 lines
1.7 KiB
C++
Raw Normal View History

2009-06-02 17:52:33 +00:00
//===- lib/Linker/Linker.cpp - Basic Linker functionality ----------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains basic Linker functionality that all usages will need.
//
//===----------------------------------------------------------------------===//
#include "llvm/Linker.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/Module.h"
2009-06-02 17:52:33 +00:00
#include "llvm/Support/MemoryBuffer.h"
2009-10-14 17:57:32 +00:00
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
2009-06-02 17:52:33 +00:00
using namespace llvm;
2009-11-18 14:58:34 +00:00
Linker::Linker(StringRef progname, StringRef modname,
LLVMContext& C, unsigned flags):
2009-07-04 13:58:26 +00:00
Context(C),
Composite(new Module(modname, C)),
Flags(flags),
Error(),
ProgramName(progname) { }
2009-06-02 17:52:33 +00:00
2009-11-18 14:58:34 +00:00
Linker::Linker(StringRef progname, Module* aModule, unsigned flags) :
2009-07-04 13:58:26 +00:00
Context(aModule->getContext()),
Composite(aModule),
Flags(flags),
Error(),
ProgramName(progname) { }
2009-06-02 17:52:33 +00:00
Linker::~Linker() {
delete Composite;
}
bool
2009-11-18 14:58:34 +00:00
Linker::error(StringRef message) {
2009-06-02 17:52:33 +00:00
Error = message;
if (!(Flags&QuietErrors))
2009-10-14 17:57:32 +00:00
errs() << ProgramName << ": error: " << message << "\n";
2009-06-02 17:52:33 +00:00
return true;
}
bool
2009-11-18 14:58:34 +00:00
Linker::warning(StringRef message) {
2009-06-02 17:52:33 +00:00
Error = message;
if (!(Flags&QuietWarnings))
2009-10-14 17:57:32 +00:00
errs() << ProgramName << ": warning: " << message << "\n";
2009-06-02 17:52:33 +00:00
return false;
}
void
2009-11-18 14:58:34 +00:00
Linker::verbose(StringRef message) {
2009-06-02 17:52:33 +00:00
if (Flags&Verbose)
2009-10-14 17:57:32 +00:00
errs() << " " << message << "\n";
2009-06-02 17:52:33 +00:00
}
Module*
Linker::releaseModule() {
Module* result = Composite;
Error.clear();
Composite = 0;
Flags = 0;
return result;
}