]> granicus.if.org Git - clang/commitdiff
createOutputFile should set Error to something if it returns null.
authorDouglas Katzman <dougk@google.com>
Thu, 17 Sep 2015 16:45:12 +0000 (16:45 +0000)
committerDouglas Katzman <dougk@google.com>
Thu, 17 Sep 2015 16:45:12 +0000 (16:45 +0000)
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

index dfd71afca486fa588e77f0761126d720c712970c..3326b81e609658e37fc4d83d949a1aa6e386be0f 100644 (file)
@@ -641,8 +641,10 @@ std::unique_ptr<llvm::raw_pwrite_stream> 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'