r234597 - Use a std::unique_ptr to make it easier to see who owns the stream.
Timur Iskhodzhanov
timurrrr at google.com
Fri Apr 10 08:09:44 PDT 2015
Looks like MSVC isn't happy with this change:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/2488/steps/run%20tests/logs/stdio
[12/88] Building CXX object
tools\clang\lib\Frontend\CMakeFiles\clangFrontend.dir\CompilerInstance.cpp.obj
[13/88] Building CXX object
tools\clang\lib\Frontend\CMakeFiles\clangFrontend.dir\CreateInvocationFromCommandLine.cpp.obj
FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\cl.exe /nologo /TP /DWIN32
/D_WINDOWS /W3 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
-wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503
-wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610
-wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389
-wd4611 -wd4805 -wd4204 -w14062 -we4238 /MD /O2 /Ob2
-Itools\clang\lib\Frontend
-IC:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend
-IC:\b\slave\sanitizer-windows\llvm\tools\clang\include
-Itools\clang\include -Iinclude
-IC:\b\slave\sanitizer-windows\llvm\include -UNDEBUG /EHs-c- /GR-
/showIncludes -DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_OBJC_REWRITER
-DCLANG_ENABLE_STATIC_ANALYZER -DGTEST_HAS_RTTI=0
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE
-D_SCL_SECURE_NO_WARNINGS -D__STDC_CONSTANT_MACROS
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
/Fotools\clang\lib\Frontend\CMakeFiles\clangFrontend.dir\CompilerInstance.cpp.obj
/Fdtools\clang\lib\Frontend\CMakeFiles\clangFrontend.dir\ /FS -c
C:\b\slave\sanitizer-windows\llvm\tools\clang\lib\Frontend\CompilerInstance.cpp
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\INCLUDE\vector(254) : error C2280:
'std::unique_ptr<llvm::raw_ostream,std::default_delete<_Ty>>::unique_ptr(const
std::unique_ptr<_Ty,std::default_delete<_Ty>> &)' : attempting to
reference a deleted function
with
[
_Ty=llvm::raw_ostream
]
C:\Program Files (x86)\Microsoft Visual Studio
12.0\VC\INCLUDE\memory(1486) : see declaration of
'std::unique_ptr<llvm::raw_ostream,std::default_delete<_Ty>>::unique_ptr'
with
[
_Ty=llvm::raw_ostream
]
This diagnostic occurred in the compiler generated function
'clang::CompilerInstance::OutputFile::OutputFile(const
clang::CompilerInstance::OutputFile &)'
ninja: build stopped: subcommand failed.
пт, 10 апр. 2015 г. в 17:17, Rafael Espindola <rafael.espindola at gmail.com>:
> Author: rafael
> Date: Fri Apr 10 09:11:52 2015
> New Revision: 234597
>
> URL: http://llvm.org/viewvc/llvm-project?rev=234597&view=rev
> Log:
> Use a std::unique_ptr to make it easier to see who owns the stream.
>
> Modified:
> cfe/trunk/include/clang/Frontend/CompilerInstance.h
> 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=234597&r1=234596&r2=234597&view=diff
> ============================================================
> ==================
> --- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
> +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Fri Apr 10
> 09:11:52 2015
> @@ -151,11 +151,11 @@ class CompilerInstance : public ModuleLo
> struct OutputFile {
> std::string Filename;
> std::string TempFilename;
> - raw_ostream *OS;
> + std::unique_ptr<raw_ostream> OS;
>
> OutputFile(const std::string &filename, const std::string
> &tempFilename,
> - raw_ostream *os)
> - : Filename(filename), TempFilename(tempFilename), OS(os) { }
> + std::unique_ptr<raw_ostream> OS)
> + : Filename(filename), TempFilename(tempFilename),
> OS(std::move(OS)) {}
> };
>
> /// The list of active output files.
> @@ -518,7 +518,7 @@ public:
> /// addOutputFile - Add an output file onto the list of tracked output
> files.
> ///
> /// \param OutFile - The output file info.
> - void addOutputFile(const OutputFile &OutFile);
> + void addOutputFile(OutputFile &&OutFile);
>
> /// clearOutputFiles - Clear the output file list, destroying the
> contained
> /// output streams.
>
> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/CompilerInstance.cpp?rev=234597&r1=234596&r2=234597&view=diff
> ============================================================
> ==================
> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Apr 10 09:11:52 2015
> @@ -518,15 +518,14 @@ void CompilerInstance::createSema(Transl
>
> // Output Files
>
> -void CompilerInstance::addOutputFile(const OutputFile &OutFile) {
> +void CompilerInstance::addOutputFile(OutputFile &&OutFile) {
> assert(OutFile.OS && "Attempt to add empty stream to output list!");
> - OutputFiles.push_back(OutFile);
> + OutputFiles.push_back(std::move(OutFile));
> }
>
> void CompilerInstance::clearOutputFiles(bool EraseFiles) {
> for (std::list<OutputFile>::iterator
> it = OutputFiles.begin(), ie = OutputFiles.end(); it != ie;
> ++it) {
> - delete it->OS;
> if (!it->TempFilename.empty()) {
> if (EraseFiles) {
> llvm::sys::fs::remove(it->TempFilename);
> @@ -561,9 +560,10 @@ CompilerInstance::createDefaultOutputFil
> }
>
> llvm::raw_null_ostream *CompilerInstance::createNullOutputFile() {
> - llvm::raw_null_ostream *OS = new llvm::raw_null_ostream();
> - addOutputFile(OutputFile("", "", OS));
> - return OS;
> + auto OS = llvm::make_unique<llvm::raw_null_ostream>();
> + llvm::raw_null_ostream *Ret = OS.get();
> + addOutputFile(OutputFile("", "", std::move(OS)));
> + return Ret;
> }
>
> llvm::raw_fd_ostream *
> @@ -575,21 +575,22 @@ CompilerInstance::createOutputFile(Strin
> bool CreateMissingDirectories) {
> std::string OutputPathName, TempPathName;
> std::error_code EC;
> - llvm::raw_fd_ostream *OS = createOutputFile(
> + std::unique_ptr<llvm::raw_fd_ostream> OS(createOutputFile(
> OutputPath, EC, Binary, RemoveFileOnSignal, InFile, Extension,
> - UseTemporary, CreateMissingDirectories, &OutputPathName,
> &TempPathName);
> + UseTemporary, CreateMissingDirectories, &OutputPathName,
> &TempPathName));
> if (!OS) {
> getDiagnostics().Report(diag::err_fe_unable_to_open_output) <<
> OutputPath
> <<
> EC.message();
> return nullptr;
> }
>
> + llvm::raw_fd_ostream *Ret = OS.get();
> // Add the output file -- but don't try to remove "-", since this means
> we are
> // using stdin.
> addOutputFile(OutputFile((OutputPathName != "-") ? OutputPathName : "",
> - TempPathName, OS));
> + TempPathName, std::move(OS)));
>
> - return OS;
> + return Ret;
> }
>
> llvm::raw_fd_ostream *CompilerInstance::createOutputFile(
>
>
> _______________________________________________
> 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/20150410/2b3e5c42/attachment.html>
More information about the cfe-commits
mailing list