2014-03-06 03:42:23 +00:00
|
|
|
//===- Linker.h - Module Linker Interface -----------------------*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-13 16:57:49 +00:00
|
|
|
|
2014-03-06 03:42:23 +00:00
|
|
|
#ifndef LLVM_LINKER_LINKER_H
|
|
|
|
#define LLVM_LINKER_LINKER_H
|
2001-10-13 16:57:49 +00:00
|
|
|
|
2013-05-04 05:05:18 +00:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2014-11-12 03:17:33 +00:00
|
|
|
#include <functional>
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2014-10-27 23:02:10 +00:00
|
|
|
namespace llvm {
|
|
|
|
class DiagnosticInfo;
|
2001-10-13 16:57:49 +00:00
|
|
|
class Module;
|
2013-05-04 05:05:18 +00:00
|
|
|
class StructType;
|
2001-10-28 21:23:44 +00:00
|
|
|
|
2013-05-04 03:06:50 +00:00
|
|
|
/// 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.
|
2004-12-13 02:58:05 +00:00
|
|
|
class Linker {
|
|
|
|
public:
|
2014-11-12 03:17:33 +00:00
|
|
|
typedef std::function<void(const DiagnosticInfo &)>
|
2014-10-27 23:02:10 +00:00
|
|
|
DiagnosticHandlerFunction;
|
|
|
|
|
|
|
|
Linker(Module *M, DiagnosticHandlerFunction DiagnosticHandler);
|
2014-10-25 04:06:10 +00:00
|
|
|
Linker(Module *M);
|
2004-12-13 02:58:05 +00:00
|
|
|
~Linker();
|
2013-10-16 08:59:57 +00:00
|
|
|
|
2013-05-04 03:06:50 +00:00
|
|
|
Module *getModule() const { return Composite; }
|
2013-10-16 08:59:57 +00:00
|
|
|
void deleteModule();
|
2013-05-04 03:06:50 +00:00
|
|
|
|
2014-10-28 00:24:16 +00:00
|
|
|
/// \brief Link \p Src into the composite. The source is destroyed.
|
2013-05-04 03:06:50 +00:00
|
|
|
/// Returns true on error.
|
2014-10-28 00:24:16 +00:00
|
|
|
bool linkInModule(Module *Src);
|
2014-10-27 23:02:10 +00:00
|
|
|
|
2014-10-28 00:24:16 +00:00
|
|
|
static bool LinkModules(Module *Dest, Module *Src,
|
|
|
|
DiagnosticHandlerFunction DiagnosticHandler);
|
2014-10-27 23:02:10 +00:00
|
|
|
|
2014-10-28 00:24:16 +00:00
|
|
|
static bool LinkModules(Module *Dest, Module *Src);
|
2004-12-13 02:58:05 +00:00
|
|
|
|
|
|
|
private:
|
2014-11-17 20:51:01 +00:00
|
|
|
void init(Module *M, DiagnosticHandlerFunction DiagnosticHandler);
|
2013-05-04 03:06:50 +00:00
|
|
|
Module *Composite;
|
2013-05-04 05:05:18 +00:00
|
|
|
SmallPtrSet<StructType*, 32> IdentifiedStructTypes;
|
2014-10-27 23:02:10 +00:00
|
|
|
DiagnosticHandlerFunction DiagnosticHandler;
|
2004-12-13 02:58:05 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-10-13 16:57:49 +00:00
|
|
|
#endif
|