Make FileOutputBuffer fail early if you pass a directory.

Previously, it created a temporary directory and then failed when
FileOutputBuffer tried to rename that file to the destination file
(which is actually a directory name).

Differential Revision: https://reviews.llvm.org/D30912

llvm-svn: 297679
This commit is contained in:
Rui Ueyama 2017-03-13 22:19:05 +00:00
parent 784f241b59
commit fed8b570b7
2 changed files with 5 additions and 0 deletions

View File

@ -20,6 +20,9 @@
# discovered we haven't bailed out early as expected.
# CHECK-NOT: undefined_symbol
# RUN: not ld.lld %t.o -o / 2>&1 | FileCheck %s -check-prefixes=ROOT
# ROOT: error: cannot open output file /
.globl _start
_start:
call undefined_symbol

View File

@ -57,6 +57,8 @@ FileOutputBuffer::create(StringRef FilePath, size_t Size, unsigned Flags) {
// FIXME: In posix, you use the access() call to check this.
}
break;
case sys::fs::file_type::directory_file:
return errc::is_a_directory;
default:
if (EC)
return EC;