LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Linker.h
Go to the documentation of this file.
1 //===- llvm/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_H
11 #define LLVM_LINKER_H
12 
13 #include "llvm/ADT/SmallPtrSet.h"
14 #include <string>
15 
16 namespace llvm {
17 
18 class Module;
19 class StringRef;
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  enum LinkerMode {
29  DestroySource = 0, // Allow source module to be destroyed.
30  PreserveSource = 1 // Preserve the source module.
31  };
32 
33  Linker(Module *M);
34  ~Linker();
35 
36  Module *getModule() const { return Composite; }
37  void deleteModule();
38 
39  /// \brief Link \p Src into the composite. The source is destroyed if
40  /// \p Mode is DestroySource and preserved if it is PreserveSource.
41  /// If \p ErrorMsg is not null, information about any error is written
42  /// to it.
43  /// Returns true on error.
44  bool linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg);
45  bool linkInModule(Module *Src, std::string *ErrorMsg) {
46  return linkInModule(Src, Linker::DestroySource, ErrorMsg);
47  }
48 
49  static bool LinkModules(Module *Dest, Module *Src, unsigned Mode,
50  std::string *ErrorMsg);
51 
52  private:
53  Module *Composite;
54  SmallPtrSet<StructType*, 32> IdentifiedStructTypes;
55 };
56 
57 } // End llvm namespace
58 
59 #endif
The main container class for the LLVM Intermediate Representation.
Definition: Module.h:112
void deleteModule()
Linker(Module *M)
bool linkInModule(Module *Src, std::string *ErrorMsg)
Definition: Linker.h:45
static bool LinkModules(Module *Dest, Module *Src, unsigned Mode, std::string *ErrorMsg)
bool linkInModule(Module *Src, unsigned Mode, std::string *ErrorMsg)
Link Src into the composite. The source is destroyed if Mode is DestroySource and preserved if it is ...
Module * getModule() const
Definition: Linker.h:36