Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
//===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
 
9
#ifndef LLVM_LINKER_LINKER_H
10
#define LLVM_LINKER_LINKER_H
11
 
12
#include "llvm/ADT/StringSet.h"
13
#include "llvm/Linker/IRMover.h"
14
 
15
namespace llvm {
16
class Module;
17
 
18
/// This class provides the core functionality of linking in LLVM. It keeps a
19
/// pointer to the merged module so far. It doesn't take ownership of the
20
/// module since it is assumed that the user of this class will want to do
21
/// something with it after the linking.
22
class Linker {
23
  IRMover Mover;
24
 
25
public:
26
  enum Flags {
27
    None = 0,
28
    OverrideFromSrc = (1 << 0),
29
    LinkOnlyNeeded = (1 << 1),
30
  };
31
 
32
  Linker(Module &M);
33
 
34
  /// Link \p Src into the composite.
35
  ///
36
  /// Passing OverrideSymbols as true will have symbols from Src
37
  /// shadow those in the Dest.
38
  ///
39
  /// Passing InternalizeCallback will have the linker call the function with
40
  /// the new module and a list of global value names to be internalized by the
41
  /// callback.
42
  ///
43
  /// Returns true on error.
44
  bool linkInModule(std::unique_ptr<Module> Src, unsigned Flags = Flags::None,
45
                    std::function<void(Module &, const StringSet<> &)>
46
                        InternalizeCallback = {});
47
 
48
  static bool linkModules(Module &Dest, std::unique_ptr<Module> Src,
49
                          unsigned Flags = Flags::None,
50
                          std::function<void(Module &, const StringSet<> &)>
51
                              InternalizeCallback = {});
52
};
53
 
54
} // End llvm namespace
55
 
56
#endif