Move LTOModule and LTOCodeGenerator to the llvm namespace.

llvm-svn: 207911
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h
index 84e22b3..51079896 100644
--- a/llvm/include/llvm-c/lto.h
+++ b/llvm/include/llvm-c/lto.h
@@ -84,10 +84,10 @@
 } lto_codegen_model;
 
 /** opaque reference to a loaded object module */
-typedef struct LTOModule*         lto_module_t;
+typedef struct LLVMOpaqueLTOModule *lto_module_t;
 
 /** opaque reference to a code generator */
-typedef struct LTOCodeGenerator*  lto_code_gen_t;
+typedef struct LLVMOpaqueLTOCodeGenerator *lto_code_gen_t;
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/llvm/include/llvm/LTO/LTOCodeGenerator.h b/llvm/include/llvm/LTO/LTOCodeGenerator.h
index ee3b90d..bef6e9c 100644
--- a/llvm/include/llvm/LTO/LTOCodeGenerator.h
+++ b/llvm/include/llvm/LTO/LTOCodeGenerator.h
@@ -53,7 +53,6 @@
   class TargetLibraryInfo;
   class TargetMachine;
   class raw_ostream;
-}
 
 //===----------------------------------------------------------------------===//
 /// C++ class which implements the opaque lto_code_gen_t type.
@@ -67,7 +66,7 @@
   // Merge given module, return true on success.
   bool addModule(struct LTOModule*, std::string &errMsg);
 
-  void setTargetOptions(llvm::TargetOptions options);
+  void setTargetOptions(TargetOptions options);
   void setDebugInfo(lto_debug_model);
   void setCodePICModel(lto_codegen_model);
 
@@ -120,41 +119,37 @@
 private:
   void initializeLTOPasses();
 
-  bool generateObjectFile(llvm::raw_ostream &out,
-                          bool disableOpt,
-                          bool disableInline,
-                          bool disableGVNLoadPRE,
-                          std::string &errMsg);
+  bool generateObjectFile(raw_ostream &out, bool disableOpt, bool disableInline,
+                          bool disableGVNLoadPRE, std::string &errMsg);
   void applyScopeRestrictions();
-  void applyRestriction(llvm::GlobalValue &GV,
-                        const llvm::ArrayRef<llvm::StringRef> &Libcalls,
-                        std::vector<const char*> &MustPreserveList,
-                        llvm::SmallPtrSet<llvm::GlobalValue*, 8> &AsmUsed,
-                        llvm::Mangler &Mangler);
+  void applyRestriction(GlobalValue &GV, const ArrayRef<StringRef> &Libcalls,
+                        std::vector<const char *> &MustPreserveList,
+                        SmallPtrSet<GlobalValue *, 8> &AsmUsed,
+                        Mangler &Mangler);
   bool determineTarget(std::string &errMsg);
 
-  static void DiagnosticHandler(const llvm::DiagnosticInfo &DI, void *Context);
+  static void DiagnosticHandler(const DiagnosticInfo &DI, void *Context);
 
-  void DiagnosticHandler2(const llvm::DiagnosticInfo &DI);
+  void DiagnosticHandler2(const DiagnosticInfo &DI);
 
-  typedef llvm::StringMap<uint8_t> StringSet;
+  typedef StringMap<uint8_t> StringSet;
 
-  llvm::LLVMContext &Context;
-  llvm::Linker Linker;
-  llvm::TargetMachine *TargetMach;
+  LLVMContext &Context;
+  Linker Linker;
+  TargetMachine *TargetMach;
   bool EmitDwarfDebugInfo;
   bool ScopeRestrictionsDone;
   lto_codegen_model CodeModel;
   StringSet MustPreserveSymbols;
   StringSet AsmUndefinedRefs;
-  llvm::MemoryBuffer *NativeObjectFile;
+  MemoryBuffer *NativeObjectFile;
   std::vector<char *> CodegenOptions;
   std::string MCpu;
   std::string MAttr;
   std::string NativeObjectPath;
-  llvm::TargetOptions Options;
+  TargetOptions Options;
   lto_diagnostic_handler_t DiagHandler;
   void *DiagContext;
 };
-
+}
 #endif // LTO_CODE_GENERATOR_H
diff --git a/llvm/include/llvm/LTO/LTOModule.h b/llvm/include/llvm/LTO/LTOModule.h
index 66ce88d..f1b1480 100644
--- a/llvm/include/llvm/LTO/LTOModule.h
+++ b/llvm/include/llvm/LTO/LTOModule.h
@@ -31,25 +31,24 @@
   class MemoryBuffer;
   class TargetOptions;
   class Value;
-}
 
 //===----------------------------------------------------------------------===//
 /// C++ class which implements the opaque lto_module_t type.
 ///
 struct LTOModule {
 private:
-  typedef llvm::StringMap<uint8_t> StringSet;
+  typedef StringMap<uint8_t> StringSet;
 
   struct NameAndAttributes {
     const char        *name;
     uint32_t           attributes;
     bool               isFunction;
-    const llvm::GlobalValue *symbol;
+    const GlobalValue *symbol;
   };
 
-  std::unique_ptr<llvm::Module>           _module;
-  std::unique_ptr<llvm::TargetMachine>    _target;
-  llvm::MCObjectFileInfo ObjFileInfo;
+  std::unique_ptr<Module> _module;
+  std::unique_ptr<TargetMachine> _target;
+  MCObjectFileInfo ObjFileInfo;
   StringSet                               _linkeropt_strings;
   std::vector<const char *>               _deplibs;
   std::vector<const char *>               _linkeropts;
@@ -57,14 +56,15 @@
 
   // _defines and _undefines only needed to disambiguate tentative definitions
   StringSet                               _defines;
-  llvm::StringMap<NameAndAttributes>      _undefines;
+  StringMap<NameAndAttributes> _undefines;
   std::vector<const char*>                _asm_undefines;
-  llvm::MCContext                         _context;
+  MCContext _context;
 
   // Use mangler to add GlobalPrefix to names to match linker names.
-  llvm::Mangler                           _mangler;
+  Mangler _mangler;
 
-  LTOModule(llvm::Module *m, llvm::TargetMachine *t);
+  LTOModule(Module *m, TargetMachine *t);
+
 public:
   /// Returns 'true' if the file or memory contents is LLVM bitcode.
   static bool isBitcodeFile(const void *mem, size_t length);
@@ -86,20 +86,16 @@
   /// InitializeAllTargetMCs();
   /// InitializeAllAsmPrinters();
   /// InitializeAllAsmParsers();
-  static LTOModule *makeLTOModule(const char* path,
-                                  llvm::TargetOptions options,
+  static LTOModule *makeLTOModule(const char *path, TargetOptions options,
                                   std::string &errMsg);
-  static LTOModule *makeLTOModule(int fd, const char *path,
-                                  size_t size, llvm::TargetOptions options,
+  static LTOModule *makeLTOModule(int fd, const char *path, size_t size,
+                                  TargetOptions options, std::string &errMsg);
+  static LTOModule *makeLTOModule(int fd, const char *path, size_t map_size,
+                                  off_t offset, TargetOptions options,
                                   std::string &errMsg);
-  static LTOModule *makeLTOModule(int fd, const char *path,
-                                  size_t map_size,
-                                  off_t offset, llvm::TargetOptions options,
-                                  std::string& errMsg);
   static LTOModule *makeLTOModule(const void *mem, size_t length,
-                                  llvm::TargetOptions options,
-                                  std::string &errMsg,
-                                  llvm::StringRef path = "");
+                                  TargetOptions options, std::string &errMsg,
+                                  StringRef path = "");
 
   /// Return the Module's target triple.
   const char *getTargetTriple() {
@@ -155,7 +151,7 @@
   }
 
   /// Return the Module.
-  llvm::Module *getLLVVMModule() { return _module.get(); }
+  Module *getLLVVMModule() { return _module.get(); }
 
   const std::vector<const char*> &getAsmUndefinedRefs() {
     return _asm_undefines;
@@ -171,16 +167,16 @@
   bool parseSymbols(std::string &errMsg);
 
   /// Add a symbol which isn't defined just yet to a list to be resolved later.
-  void addPotentialUndefinedSymbol(const llvm::GlobalValue *dcl, bool isFunc);
+  void addPotentialUndefinedSymbol(const GlobalValue *dcl, bool isFunc);
 
   /// Add a defined symbol to the list.
-  void addDefinedSymbol(const llvm::GlobalValue *def, bool isFunction);
+  void addDefinedSymbol(const GlobalValue *def, bool isFunction);
 
   /// Add a function symbol as defined to the list.
-  void addDefinedFunctionSymbol(const llvm::Function *f);
+  void addDefinedFunctionSymbol(const Function *f);
 
   /// Add a data symbol as defined to the list.
-  void addDefinedDataSymbol(const llvm::GlobalValue *v);
+  void addDefinedDataSymbol(const GlobalValue *v);
 
   /// Add global symbols from module-level ASM to the defined or undefined
   /// lists.
@@ -193,30 +189,28 @@
   void addAsmGlobalSymbolUndef(const char *);
 
   /// Parse i386/ppc ObjC class data structure.
-  void addObjCClass(const llvm::GlobalVariable *clgv);
+  void addObjCClass(const GlobalVariable *clgv);
 
   /// Parse i386/ppc ObjC category data structure.
-  void addObjCCategory(const llvm::GlobalVariable *clgv);
+  void addObjCCategory(const GlobalVariable *clgv);
 
   /// Parse i386/ppc ObjC class list data structure.
-  void addObjCClassRef(const llvm::GlobalVariable *clgv);
+  void addObjCClassRef(const GlobalVariable *clgv);
 
   /// Get string that the data pointer points to.
-  bool objcClassNameFromExpression(const llvm::Constant* c, std::string &name);
+  bool objcClassNameFromExpression(const Constant *c, std::string &name);
 
   /// Returns 'true' if the memory buffer is for the specified target triple.
-  static bool isTargetMatch(llvm::MemoryBuffer *memBuffer,
-                            const char *triplePrefix);
+  static bool isTargetMatch(MemoryBuffer *memBuffer, const char *triplePrefix);
 
   /// Create an LTOModule (private version). N.B. This method takes ownership of
   /// the buffer.
-  static LTOModule *makeLTOModule(llvm::MemoryBuffer *buffer,
-                                  llvm::TargetOptions options,
+  static LTOModule *makeLTOModule(MemoryBuffer *buffer, TargetOptions options,
                                   std::string &errMsg);
 
   /// Create a MemoryBuffer from a memory range with an optional name.
-  static llvm::MemoryBuffer *makeBuffer(const void *mem, size_t length,
-                                        llvm::StringRef name = "");
+  static MemoryBuffer *makeBuffer(const void *mem, size_t length,
+                                  StringRef name = "");
 };
-
+}
 #endif // LTO_MODULE_H