r247900 - createOutputFile should set Error to something if it returns null.

Douglas Katzman via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 09:45:12 PDT 2015


Author: dougk
Date: Thu Sep 17 11:45:12 2015
New Revision: 247900

URL: http://llvm.org/viewvc/llvm-project?rev=247900&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=247900&r1=247899&r2=247900&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Sep 17 11:45:12 2015
@@ -641,8 +641,10 @@ std::unique_ptr<llvm::raw_pwrite_stream>
       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'




More information about the cfe-commits mailing list