diff options
author | Stephen Hines <srhines@google.com> | 2014-04-23 16:57:46 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-04-24 15:53:16 -0700 |
commit | 36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch) | |
tree | e6cfb69fbbd937f450eeb83bfb83b9da3b01275a /include/llvm/Linker | |
parent | 69a8640022b04415ae9fac62f8ab090601d8f889 (diff) | |
download | external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2 |
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'include/llvm/Linker')
-rw-r--r-- | include/llvm/Linker/Linker.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/llvm/Linker/Linker.h b/include/llvm/Linker/Linker.h new file mode 100644 index 0000000..42b2cb3 --- /dev/null +++ b/include/llvm/Linker/Linker.h @@ -0,0 +1,61 @@ +//===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LINKER_LINKER_H +#define LLVM_LINKER_LINKER_H + +#include "llvm/ADT/SmallPtrSet.h" +#include <string> + +namespace llvm { + +class Module; +class StringRef; +class StructType; + +/// This class provides the core functionality of linking in LLVM. It keeps a +/// pointer to the merged module so far. It doesn't take ownership of the +/// module since it is assumed that the user of this class will want to do +/// something with it after the linking. +class Linker { + public: + enum LinkerMode { + DestroySource = 0, // Allow source module to be destroyed. + PreserveSource = 1 // Preserve the source module. + }; + + Linker(Module *M, bool SuppressWarnings=false); + ~Linker(); + + Module *getModule() const { return Composite; } + void deleteModule(); + + /// \brief Link \p Src into the composite. The source is destroyed if + /// \p Mode is DestroySource and preserved if it is PreserveSource. + /// If \p ErrorMsg is not null, information about any error is written + /// to it. + /// Returns true on error. + bool linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg); + bool linkInModule(Module *Src, std::string *ErrorMsg) { + return linkInModule(Src, Linker::DestroySource, ErrorMsg); + } + + static bool LinkModules(Module *Dest, Module *Src, unsigned Mode, + std::string *ErrorMsg); + + private: + Module *Composite; + SmallPtrSet<StructType*, 32> IdentifiedStructTypes; + + bool SuppressWarnings; +}; + +} // End llvm namespace + +#endif |