Remove the PreserveSource linker mode.
[oota-llvm.git] / include / llvm / Linker / Linker.h
1 //===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_LINKER_LINKER_H
11 #define LLVM_LINKER_LINKER_H
12
13 #include "llvm/ADT/SmallPtrSet.h"
14
15 #include <functional>
16
17 namespace llvm {
18 class DiagnosticInfo;
19 class Module;
20 class StructType;
21
22 /// This class provides the core functionality of linking in LLVM. It keeps a
23 /// pointer to the merged module so far. It doesn't take ownership of the
24 /// module since it is assumed that the user of this class will want to do
25 /// something with it after the linking.
26 class Linker {
27   public:
28     typedef std::function<void(const DiagnosticInfo &)>
29         DiagnosticHandlerFunction;
30
31     Linker(Module *M, DiagnosticHandlerFunction DiagnosticHandler);
32     Linker(Module *M);
33     ~Linker();
34
35     Module *getModule() const { return Composite; }
36     void deleteModule();
37
38     /// \brief Link \p Src into the composite. The source is destroyed.
39     /// Returns true on error.
40     bool linkInModule(Module *Src);
41
42     static bool LinkModules(Module *Dest, Module *Src,
43                             DiagnosticHandlerFunction DiagnosticHandler);
44
45     static bool LinkModules(Module *Dest, Module *Src);
46
47   private:
48     Module *Composite;
49     SmallPtrSet<StructType*, 32> IdentifiedStructTypes;
50     DiagnosticHandlerFunction DiagnosticHandler;
51 };
52
53 } // End llvm namespace
54
55 #endif