Merge "Fix up MCLinker build to work with LLVM 3.5 (r209713)."
diff --git a/include/mcld/Support/MemoryArea.h b/include/mcld/Support/MemoryArea.h
index c45b8ca..2fef506 100644
--- a/include/mcld/Support/MemoryArea.h
+++ b/include/mcld/Support/MemoryArea.h
@@ -41,7 +41,7 @@
   size_t size() const;
 
 private:
-  llvm::OwningPtr<llvm::MemoryBuffer> m_pMemoryBuffer;
+  std::unique_ptr<llvm::MemoryBuffer> m_pMemoryBuffer;
 };
 
 } // namespace of mcld
diff --git a/include/mcld/Support/raw_ostream.h b/include/mcld/Support/raw_ostream.h
index e202019..aae2336 100644
--- a/include/mcld/Support/raw_ostream.h
+++ b/include/mcld/Support/raw_ostream.h
@@ -9,6 +9,7 @@
 #ifndef MCLD_SUPPORT_RAWOSTREAM_H
 #define MCLD_SUPPORT_RAWOSTREAM_H
 #include <string>
+#include <llvm/Support/FileSystem.h>
 #include <llvm/Support/raw_ostream.h>
 
 namespace mcld {
diff --git a/lib/CodeGen/MCLDTargetMachine.cpp b/lib/CodeGen/MCLDTargetMachine.cpp
index 9f71390..e1d9a0e 100644
--- a/lib/CodeGen/MCLDTargetMachine.cpp
+++ b/lib/CodeGen/MCLDTargetMachine.cpp
@@ -77,10 +77,10 @@
                        generated assembly code to make it more readable."),
               cl::init(cl::BOU_UNSET));
 
-static bool getVerboseAsm() {
+static bool getVerboseAsm(TargetMachine &TM) {
   switch (ArgAsmVerbose) {
   default:
-  case cl::BOU_UNSET: return TargetMachine::getAsmVerbosityDefault();
+  case cl::BOU_UNSET: return TM.getAsmVerbosityDefault();
   case cl::BOU_TRUE:  return true;
   case cl::BOU_FALSE: return false;
   }
@@ -212,7 +212,7 @@
   case CGFT_ASMFile: {
     assert(Context != 0 && "Failed to get MCContext");
 
-    if (getTM().hasMCSaveTempLabels())
+    if (getTM().Options.MCOptions.MCSaveTempLabels)
       Context->setAllowTemporaryLabels(false);
 
     if (addCompilerPasses(pPM,
@@ -224,7 +224,7 @@
   case CGFT_OBJFile: {
     assert(Context != 0 && "Failed to get MCContext");
 
-    if (getTM().hasMCSaveTempLabels())
+    if (getTM().Options.MCOptions.MCSaveTempLabels)
       Context->setAllowTemporaryLabels(false);
     if (addAssemblerPasses(pPM,
                            pOutput.formatted_os(),
@@ -302,9 +302,8 @@
   // now, we have MCCodeEmitter and MCAsmBackend, we can create AsmStreamer.
   OwningPtr<MCStreamer> AsmStreamer(
     m_pLLVMTarget->createAsmStreamer(*Context, pOutput,
-                                     getVerboseAsm(),
-                                     getTM().hasMCUseCFI(),
-                                     getTM().hasMCUseDwarfDirectory(),
+                                     getVerboseAsm(getTM()),
+                                     getTM().Options.MCOptions.MCUseDwarfDirectory,
                                      InstPrinter,
                                      MCE, MAB,
                                      ArgShowMCInst));
@@ -340,8 +339,8 @@
 
   // now, we have MCCodeEmitter and MCAsmBackend, we can create AsmStreamer.
   OwningPtr<MCStreamer> AsmStreamer(m_pLLVMTarget->createMCObjectStreamer(
-    m_Triple, *Context, *MAB, pOutput, MCE, STI, getTM().hasMCRelaxAll(),
-    getTM().hasMCNoExecStack()));
+    m_Triple, *Context, *MAB, pOutput, MCE, STI,
+    getTM().Options.MCOptions.MCRelaxAll, getTM().Options.MCOptions.MCNoExecStack));
 
   AsmStreamer.get()->InitSections();
   MachineFunctionPass *funcPass =
diff --git a/lib/Support/ToolOutputFile.cpp b/lib/Support/ToolOutputFile.cpp
index 92a3fab..3e4844c 100644
--- a/lib/Support/ToolOutputFile.cpp
+++ b/lib/Support/ToolOutputFile.cpp
@@ -15,6 +15,7 @@
 #include <mcld/Support/SystemUtils.h>
 #include <mcld/Support/MsgHandling.h>
 
+#include <llvm/Support/FileUtilities.h>
 #include <llvm/Support/Signals.h>
 #include <llvm/Support/Path.h>
 #include <llvm/Support/FormattedStream.h>