From cfeac986355fd3a85af687c17c452cc5fb5f11f4 Mon Sep 17 00:00:00 2001 From: Douglas Katzman Date: Thu, 17 Sep 2015 16:45:12 +0000 Subject: [PATCH] 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 --- lib/Frontend/CompilerInstance.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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' -- 2.50.1