[llvm] r194257 - llvm-ar: Let opening a directory failed in llvm-ar.
NAKAMURA Takumi
geek4civic at gmail.com
Fri Nov 8 04:35:56 PST 2013
Author: chapuni
Date: Fri Nov 8 06:35:56 2013
New Revision: 194257
URL: http://llvm.org/viewvc/llvm-project?rev=194257&view=rev
Log:
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.
Modified:
llvm/trunk/test/Object/directory.ll
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Modified: llvm/trunk/test/Object/directory.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/directory.ll?rev=194257&r1=194256&r2=194257&view=diff
==============================================================================
--- llvm/trunk/test/Object/directory.ll (original)
+++ llvm/trunk/test/Object/directory.ll Fri Nov 8 06:35:56 2013
@@ -2,9 +2,6 @@
;RUN: not llvm-ar r %T/test.a . 2>&1 | FileCheck %s
;CHECK: .: Is a directory
-; Opening a directory works on cygwin and freebsd.
-;XFAIL: freebsd, cygwin
-
;RUN: rm -f %T/test.a
;RUN: touch %T/a-very-long-file-name
;RUN: llvm-ar r %T/test.a %s %T/a-very-long-file-name
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=194257&r1=194256&r2=194257&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Fri Nov 8 06:35:56 2013
@@ -782,6 +782,13 @@ static void performWriteOperation(Archiv
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<MemoryBuffer> File;
failIfError(MemoryBuffer::getOpenFile(FD, FileName, File,
Status.getSize(), false),
More information about the llvm-commits
mailing list