r215346 - Revert r215331, "unique_ptrify CompilerInstance::OutputFile(s) and remove a unique_ptr around a non-owning raw_ostream in CodeGenAction::CreateASTConsumer"

David Blaikie dblaikie at gmail.com
Mon Aug 11 10:18:34 PDT 2014


Does msvc 2012 not generate implicit move operations?
On Aug 11, 2014 12:05 AM, "NAKAMURA Takumi" <geek4civic at gmail.com> wrote:

> Author: chapuni
> Date: Mon Aug 11 01:53:11 2014
> New Revision: 215346
>
> URL: http://llvm.org/viewvc/llvm-project?rev=215346&view=rev
> Log:
> Revert r215331, "unique_ptrify CompilerInstance::OutputFile(s) and remove
> a unique_ptr around a non-owning raw_ostream in
> CodeGenAction::CreateASTConsumer"
>
> It cannot be compiled on Visual Studio 2012.
>
>   clang\include\clang/Frontend/CompilerInstance.h(153):
> error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private
> member declared in class 'std::unique_ptr<_Ty>'
>             with
>             [
>                 _Ty=llvm::raw_ostream
>             ]
>             D:\Program Files (x86)\Microsoft Visual Studio
> 11.0\VC\include\memory(1447) : see declaration of
> 'std::unique_ptr<_Ty>::unique_ptr'
>             with
>             [
>                 _Ty=llvm::raw_ostream
>             ]
>             This diagnostic occurred in the compiler generated function
> 'clang::CompilerInstance::OutputFile::OutputFile(const
> clang::CompilerInstance::OutputFile &)'
>
> Modified:
>     cfe/trunk/include/clang/Frontend/CompilerInstance.h
>     cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>     cfe/trunk/lib/Frontend/CompilerInstance.cpp
>
> Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=215346&r1=215345&r2=215346&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
> +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Mon Aug 11
> 01:53:11 2014
> @@ -144,11 +144,11 @@ class CompilerInstance : public ModuleLo
>    struct OutputFile {
>      std::string Filename;
>      std::string TempFilename;
> -    std::unique_ptr<raw_ostream> OS;
> +    raw_ostream *OS;
>
>      OutputFile(const std::string &filename, const std::string
> &tempFilename,
> -               std::unique_ptr<raw_ostream> OS)
> -      : Filename(filename), TempFilename(tempFilename), OS(std::move(OS))
> { }
> +               raw_ostream *os)
> +      : Filename(filename), TempFilename(tempFilename), OS(os) { }
>    };
>
>    /// The list of active output files.
> @@ -508,7 +508,7 @@ public:
>    /// addOutputFile - Add an output file onto the list of tracked output
> files.
>    ///
>    /// \param OutFile - The output file info.
> -  void addOutputFile(OutputFile OutFile);
> +  void addOutputFile(const OutputFile &OutFile);
>
>    /// clearOutputFiles - Clear the output file list, destroying the
> contained
>    /// output streams.
> @@ -657,11 +657,14 @@ public:
>    /// stored here on success.
>    /// \param TempPathName [out] - If given, the temporary file path name
>    /// will be stored here on success.
> -  static std::unique_ptr<llvm::raw_fd_ostream>
> -  createOutputFile(StringRef OutputPath, std::string &Error, bool Binary,
> -                   bool RemoveFileOnSignal, StringRef BaseInput,
> -                   StringRef Extension, bool UseTemporary,
> -                   bool CreateMissingDirectories, std::string
> *ResultPathName,
> +  static llvm::raw_fd_ostream *
> +  createOutputFile(StringRef OutputPath, std::string &Error,
> +                   bool Binary, bool RemoveFileOnSignal,
> +                   StringRef BaseInput,
> +                   StringRef Extension,
> +                   bool UseTemporary,
> +                   bool CreateMissingDirectories,
> +                   std::string *ResultPathName,
>                     std::string *TempPathName);
>
>    llvm::raw_null_ostream *createNullOutputFile();
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=215346&r1=215345&r2=215346&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Aug 11 01:53:11 2014
> @@ -610,7 +610,7 @@ static raw_ostream *GetOutputStream(Comp
>  std::unique_ptr<ASTConsumer>
>  CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
>    BackendAction BA = static_cast<BackendAction>(Act);
> -  raw_ostream *OS = GetOutputStream(CI, InFile, BA);
> +  std::unique_ptr<raw_ostream> OS(GetOutputStream(CI, InFile, BA));
>    if (BA != Backend_EmitNothing && !OS)
>      return nullptr;
>
> @@ -649,7 +649,7 @@ CodeGenAction::CreateASTConsumer(Compile
>    std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
>        BA, CI.getDiagnostics(), CI.getCodeGenOpts(), CI.getTargetOpts(),
>        CI.getLangOpts(), CI.getFrontendOpts().ShowTimers, InFile,
> -      LinkModuleToUse, OS, *VMContext, CoverageInfo));
> +      LinkModuleToUse, OS.release(), *VMContext, CoverageInfo));
>    BEConsumer = Result.get();
>    return std::move(Result);
>  }
>
> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=215346&r1=215345&r2=215346&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Aug 11 01:53:11 2014
> @@ -518,15 +518,15 @@ void CompilerInstance::createSema(Transl
>
>  // Output Files
>
> -void CompilerInstance::addOutputFile(OutputFile OutFile) {
> +void CompilerInstance::addOutputFile(const OutputFile &OutFile) {
>    assert(OutFile.OS && "Attempt to add empty stream to output list!");
> -  OutputFiles.push_back(std::move(OutFile));
> +  OutputFiles.push_back(OutFile);
>  }
>
>  void CompilerInstance::clearOutputFiles(bool EraseFiles) {
>    for (std::list<OutputFile>::iterator
>           it = OutputFiles.begin(), ie = OutputFiles.end(); it != ie;
> ++it) {
> -    it->OS.reset();
> +    delete it->OS;
>      if (!it->TempFilename.empty()) {
>        if (EraseFiles) {
>          llvm::sys::fs::remove(it->TempFilename);
> @@ -561,10 +561,9 @@ CompilerInstance::createDefaultOutputFil
>  }
>
>  llvm::raw_null_ostream *CompilerInstance::createNullOutputFile() {
> -  auto OS = llvm::make_unique<llvm::raw_null_ostream>();
> -  auto *Res = OS.get();
> -  addOutputFile(OutputFile("", "", std::move(OS)));
> -  return Res;
> +  llvm::raw_null_ostream *OS = new llvm::raw_null_ostream();
> +  addOutputFile(OutputFile("", "", OS));
> +  return OS;
>  }
>
>  llvm::raw_fd_ostream *
> @@ -575,7 +574,7 @@ CompilerInstance::createOutputFile(Strin
>                                     bool UseTemporary,
>                                     bool CreateMissingDirectories) {
>    std::string Error, OutputPathName, TempPathName;
> -  auto OS = createOutputFile(OutputPath, Error, Binary,
> +  llvm::raw_fd_ostream *OS = createOutputFile(OutputPath, Error, Binary,
>                                                RemoveFileOnSignal,
>                                                InFile, Extension,
>                                                UseTemporary,
> @@ -588,16 +587,15 @@ CompilerInstance::createOutputFile(Strin
>      return nullptr;
>    }
>
> -  auto *Res = OS.get();
>    // Add the output file -- but don't try to remove "-", since this means
> we are
>    // using stdin.
>    addOutputFile(OutputFile((OutputPathName != "-") ? OutputPathName : "",
> -                           TempPathName, std::move(OS)));
> +                TempPathName, OS));
>
> -  return Res;
> +  return OS;
>  }
>
> -std::unique_ptr<llvm::raw_fd_ostream>
> +llvm::raw_fd_ostream *
>  CompilerInstance::createOutputFile(StringRef OutputPath,
>                                     std::string &Error,
>                                     bool Binary,
> @@ -665,7 +663,7 @@ CompilerInstance::createOutputFile(Strin
>      }
>
>      if (!EC) {
> -      OS = llvm::make_unique<llvm::raw_fd_ostream>(fd,
> /*shouldClose=*/true);
> +      OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true));
>        OSFile = TempFile = TempPath.str();
>      }
>      // If we failed to create the temporary, fallback to writing to the
> file
> @@ -675,9 +673,9 @@ CompilerInstance::createOutputFile(Strin
>
>    if (!OS) {
>      OSFile = OutFile;
> -    OS = llvm::make_unique<llvm::raw_fd_ostream>(
> +    OS.reset(new llvm::raw_fd_ostream(
>          OSFile.c_str(), Error,
> -        (Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text));
> +        (Binary ? llvm::sys::fs::F_None : llvm::sys::fs::F_Text)));
>      if (!Error.empty())
>        return nullptr;
>    }
> @@ -691,7 +689,7 @@ CompilerInstance::createOutputFile(Strin
>    if (TempPathName)
>      *TempPathName = TempFile;
>
> -  return OS;
> +  return OS.release();
>  }
>
>  // Initialization Utilities
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140811/3a8eb271/attachment.html>


More information about the cfe-commits mailing list