From: Douglas Katzman Date: Thu, 17 Sep 2015 16:45:12 +0000 (+0000) Subject: createOutputFile should set Error to something if it returns null. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cfeac986355fd3a85af687c17c452cc5fb5f11f4;p=clang createOutputFile should set Error to something if it returns null. This is not portably unit-testable because the only visible effect is a change from one random message string to another. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247900 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index dfd71afca4..3326b81e60 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -641,8 +641,10 @@ std::unique_ptr CompilerInstance::createOutputFile( llvm::sys::fs::status(OutputPath, Status); if (llvm::sys::fs::exists(Status)) { // Fail early if we can't write to the final destination. - if (!llvm::sys::fs::can_write(OutputPath)) + if (!llvm::sys::fs::can_write(OutputPath)) { + Error = std::make_error_code(std::errc::operation_not_permitted); return nullptr; + } // Don't use a temporary if the output is a special file. This handles // things like '-o /dev/null'