+ /// @name Types
+ /// @{
+ public:
+ /// This enumeration is used to control various optional features of the
+ /// linker.
+ enum ControlFlags {
+ Verbose = 1, ///< Print to stderr what steps the linker is taking
+ QuietWarnings = 2, ///< Don't print warnings to stderr.
+ QuietErrors = 4 ///< Don't print errors to stderr.
+ };
+
+ enum LinkerMode {
+ DestroySource = 0, // Allow source module to be destroyed.
+ PreserveSource = 1 // Preserve the source module.
+ };
+
+ /// @}
+ /// @name Constructors
+ /// @{
+ public:
+ /// Construct the Linker with an empty module which will be given the
+ /// name \p progname. \p progname will also be used for error messages.
+ /// @brief Construct with empty module
+ Linker(StringRef progname, ///< name of tool running linker
+ StringRef modulename, ///< name of linker's end-result module
+ LLVMContext &C, ///< Context for global info
+ unsigned Flags = 0 ///< ControlFlags (one or more |'d together)
+ );
+
+ /// Construct the Linker with a previously defined module, \p aModule. Use
+ /// \p progname for the name of the program in error messages.
+ /// @brief Construct with existing module
+ Linker(StringRef progname, Module* aModule, unsigned Flags = 0);
+
+ /// Destruct the Linker.
+ /// @brief Destructor
+ ~Linker();
+
+ /// @}
+ /// @name Accessors
+ /// @{
+ public:
+ /// This method gets the composite module into which linking is being
+ /// done. The Composite module starts out empty and accumulates modules
+ /// linked into it via the various LinkIn* methods. This method does not
+ /// release the Module to the caller. The Linker retains ownership and will
+ /// destruct the Module when the Linker is destructed.
+ /// @see releaseModule
+ /// @brief Get the linked/composite module.
+ Module* getModule() const { return Composite; }
+
+ /// This method releases the composite Module into which linking is being
+ /// done. Ownership of the composite Module is transferred to the caller who
+ /// must arrange for its destruct. After this method is called, the Linker
+ /// terminates the linking session for the returned Module. It will no
+ /// longer utilize the returned Module but instead resets itself for
+ /// subsequent linking as if the constructor had been called. The Linker's
+ /// LibPaths and flags to be reset, and memory will be released.
+ /// @brief Release the linked/composite module.
+ Module* releaseModule();
+
+ /// This method gets the list of libraries that form the path that the
+ /// Linker will search when it is presented with a library name.
+ /// @brief Get the Linkers library path
+ const std::vector<sys::Path>& getLibPaths() const { return LibPaths; }
+
+ /// This method returns an error string suitable for printing to the user.
+ /// The return value will be empty unless an error occurred in one of the
+ /// LinkIn* methods. In those cases, the LinkIn* methods will have returned
+ /// true, indicating an error occurred. At most one error is retained so
+ /// this function always returns the last error that occurred. Note that if
+ /// the Quiet control flag is not set, the error string will have already
+ /// been printed to stderr.
+ /// @brief Get the text of the last error that occurred.
+ const std::string &getLastError() const { return Error; }