<p dir="ltr">Does msvc 2012 not generate implicit move operations?</p>
<div class="gmail_quote">On Aug 11, 2014 12:05 AM, "NAKAMURA Takumi" <<a href="mailto:geek4civic@gmail.com">geek4civic@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: chapuni<br>
Date: Mon Aug 11 01:53:11 2014<br>
New Revision: 215346<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=215346&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=215346&view=rev</a><br>
Log:<br>
Revert r215331, "unique_ptrify CompilerInstance::OutputFile(s) and remove a unique_ptr around a non-owning raw_ostream in CodeGenAction::CreateASTConsumer"<br>
<br>
It cannot be compiled on Visual Studio 2012.<br>
<br>
  clang\include\clang/Frontend/CompilerInstance.h(153):<br>
error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>'<br>
            with<br>
            [<br>
                _Ty=llvm::raw_ostream<br>
            ]<br>
            D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\memory(1447) : see declaration of 'std::unique_ptr<_Ty>::unique_ptr'<br>
            with<br>
            [<br>
                _Ty=llvm::raw_ostream<br>
            ]<br>
            This diagnostic occurred in the compiler generated function 'clang::CompilerInstance::OutputFile::OutputFile(const clang::CompilerInstance::OutputFile &)'<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Frontend/CompilerInstance.h<br>
    cfe/trunk/lib/CodeGen/CodeGenAction.cpp<br>
    cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=215346&r1=215345&r2=215346&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=215346&r1=215345&r2=215346&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)<br>
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Mon Aug 11 01:53:11 2014<br>
@@ -144,11 +144,11 @@ class CompilerInstance : public ModuleLo<br>
   struct OutputFile {<br>
     std::string Filename;<br>
     std::string TempFilename;<br>
-    std::unique_ptr<raw_ostream> OS;<br>
+    raw_ostream *OS;<br>
<br>
     OutputFile(const std::string &filename, const std::string &tempFilename,<br>
-               std::unique_ptr<raw_ostream> OS)<br>
-      : Filename(filename), TempFilename(tempFilename), OS(std::move(OS)) { }<br>
+               raw_ostream *os)<br>
+      : Filename(filename), TempFilename(tempFilename), OS(os) { }<br>
   };<br>
<br>
   /// The list of active output files.<br>
@@ -508,7 +508,7 @@ public:<br>
   /// addOutputFile - Add an output file onto the list of tracked output files.<br>
   ///<br>
   /// \param OutFile - The output file info.<br>
-  void addOutputFile(OutputFile OutFile);<br>
+  void addOutputFile(const OutputFile &OutFile);<br>
<br>
   /// clearOutputFiles - Clear the output file list, destroying the contained<br>
   /// output streams.<br>
@@ -657,11 +657,14 @@ public:<br>
   /// stored here on success.<br>
   /// \param TempPathName [out] - If given, the temporary file path name<br>
   /// will be stored here on success.<br>
-  static std::unique_ptr<llvm::raw_fd_ostream><br>
-  createOutputFile(StringRef OutputPath, std::string &Error, bool Binary,<br>
-                   bool RemoveFileOnSignal, StringRef BaseInput,<br>
-                   StringRef Extension, bool UseTemporary,<br>
-                   bool CreateMissingDirectories, std::string *ResultPathName,<br>
+  static llvm::raw_fd_ostream *<br>
+  createOutputFile(StringRef OutputPath, std::string &Error,<br>
+                   bool Binary, bool RemoveFileOnSignal,<br>
+                   StringRef BaseInput,<br>
+                   StringRef Extension,<br>
+                   bool UseTemporary,<br>
+                   bool CreateMissingDirectories,<br>
+                   std::string *ResultPathName,<br>
                    std::string *TempPathName);<br>
<br>
   llvm::raw_null_ostream *createNullOutputFile();<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=215346&r1=215345&r2=215346&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=215346&r1=215345&r2=215346&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Aug 11 01:53:11 2014<br>
@@ -610,7 +610,7 @@ static raw_ostream *GetOutputStream(Comp<br>
 std::unique_ptr<ASTConsumer><br>
 CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {<br>
   BackendAction BA = static_cast<BackendAction>(Act);<br>
-  raw_ostream *OS = GetOutputStream(CI, InFile, BA);<br>
+  std::unique_ptr<raw_ostream> OS(GetOutputStream(CI, InFile, BA));<br>
   if (BA != Backend_EmitNothing && !OS)<br>
     return nullptr;<br>
<br>
@@ -649,7 +649,7 @@ CodeGenAction::CreateASTConsumer(Compile<br>
   std::unique_ptr<BackendConsumer> Result(new BackendConsumer(<br>
       BA, CI.getDiagnostics(), CI.getCodeGenOpts(), CI.getTargetOpts(),<br>
       CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile,<br>
-      LinkModuleToUse, OS, *VMContext, CoverageInfo));<br>
+      LinkModuleToUse, OS.release(), *VMContext, CoverageInfo));<br>
   BEConsumer = Result.get();<br>
   return std::move(Result);<br>
 }<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=215346&r1=215345&r2=215346&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=215346&r1=215345&r2=215346&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Aug 11 01:53:11 2014<br>
@@ -518,15 +518,15 @@ void CompilerInstance::createSema(Transl<br>
<br>
 // Output Files<br>
<br>
-void CompilerInstance::addOutputFile(OutputFile OutFile) {<br>
+void CompilerInstance::addOutputFile(const OutputFile &OutFile) {<br>
   assert(OutFile.OS && "Attempt to add empty stream to output list!");<br>
-  OutputFiles.push_back(std::move(OutFile));<br>
+  OutputFiles.push_back(OutFile);<br>
 }<br>
<br>
 void CompilerInstance::clearOutputFiles(bool EraseFiles) {<br>
   for (std::list<OutputFile>::iterator<br>
          it = OutputFiles.begin(), ie = OutputFiles.end(); it != ie; ++it) {<br>
-    it->OS.reset();<br>
+    delete it->OS;<br>
     if (!it->TempFilename.empty()) {<br>
       if (EraseFiles) {<br>
         llvm::sys::fs::remove(it->TempFilename);<br>
@@ -561,10 +561,9 @@ CompilerInstance::createDefaultOutputFil<br>
 }<br>
<br>
 llvm::raw_null_ostream *CompilerInstance::createNullOutputFile() {<br>
-  auto OS = llvm::make_unique<llvm::raw_null_ostream>();<br>
-  auto *Res = OS.get();<br>
-  addOutputFile(OutputFile("", "", std::move(OS)));<br>
-  return Res;<br>
+  llvm::raw_null_ostream *OS = new llvm::raw_null_ostream();<br>
+  addOutputFile(OutputFile("", "", OS));<br>
+  return OS;<br>
 }<br>
<br>
 llvm::raw_fd_ostream *<br>
@@ -575,7 +574,7 @@ CompilerInstance::createOutputFile(Strin<br>
                                    bool UseTemporary,<br>
                                    bool CreateMissingDirectories) {<br>
   std::string Error, OutputPathName, TempPathName;<br>
-  auto OS = createOutputFile(OutputPath, Error, Binary,<br>
+  llvm::raw_fd_ostream *OS = createOutputFile(OutputPath, Error, Binary,<br>
                                               RemoveFileOnSignal,<br>
                                               InFile, Extension,<br>
                                               UseTemporary,<br>
@@ -588,16 +587,15 @@ CompilerInstance::createOutputFile(Strin<br>
     return nullptr;<br>
   }<br>
<br>
-  auto *Res = OS.get();<br>
   // Add the output file -- but don't try to remove "-", since this means we are<br>
   // using stdin.<br>
   addOutputFile(OutputFile((OutputPathName != "-") ? OutputPathName : "",<br>
-                           TempPathName, std::move(OS)));<br>
+                TempPathName, OS));<br>
<br>
-  return Res;<br>
+  return OS;<br>
 }<br>
<br>
-std::unique_ptr<llvm::raw_fd_ostream><br>
+llvm::raw_fd_ostream *<br>
 CompilerInstance::createOutputFile(StringRef OutputPath,<br>
                                    std::string &Error,<br>
                                    bool Binary,<br>
@@ -665,7 +663,7 @@ CompilerInstance::createOutputFile(Strin<br>
     }<br>
<br>
     if (!EC) {<br>
-      OS = llvm::make_unique<llvm::raw_fd_ostream>(fd, /*shouldClose=*/true);<br>
+      OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true));<br>
       OSFile = TempFile = TempPath.str();<br>
     }<br>
     // If we failed to create the temporary, fallback to writing to the file<br>
@@ -675,9 +673,9 @@ CompilerInstance::createOutputFile(Strin<br>
<br>
   if (!OS) {<br>
     OSFile = OutFile;<br>
-    OS = llvm::make_unique<llvm::raw_fd_ostream>(<br>
+    OS.reset(new llvm::raw_fd_ostream(<br>
         OSFile.c_str(), Error,<br>
-        (Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text));<br>
+        (Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text)));<br>
     if (!Error.empty())<br>
       return nullptr;<br>
   }<br>
@@ -691,7 +689,7 @@ CompilerInstance::createOutputFile(Strin<br>
   if (TempPathName)<br>
     *TempPathName = TempFile;<br>
<br>
-  return OS;<br>
+  return OS.release();<br>
 }<br>
<br>
 // Initialization Utilities<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>