From 6af8781854a15eadb9df6b45f27fa5cceda5eb16 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Fri, 8 Nov 2013 12:35:56 +0000 Subject: llvm-ar: Let opening a directory failed in llvm-ar. Linux cannot open directories with open(2), although cygwin and *bsd can. Motivation: The test, Object/directory.ll, had been failing with --target=cygwin on Linux. XFAIL was improper for host issues. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194257 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-ar/llvm-ar.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tools/llvm-ar') diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 64ef3fa1bb..d70db728f2 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -782,6 +782,13 @@ static void performWriteOperation(ArchiveOperation Operation, sys::fs::file_status Status; failIfError(sys::fs::status(FD, Status), FileName); + // Opening a directory doesn't make sense. Let it failed. + // Linux cannot open directories with open(2), although + // cygwin and *bsd can. + if (Status.type() == sys::fs::file_type::directory_file) + failIfError(error_code(errc::is_a_directory, posix_category()), + FileName); + OwningPtr File; failIfError(MemoryBuffer::getOpenFile(FD, FileName, File, Status.getSize(), false), -- cgit v1.2.3