[PATCH] D30912: Make FileOutputBuffer fail early if you pass a directory.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 15:27:36 PDT 2017


LGTM

Rui Ueyama via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:

> ruiu created this revision.
>
> Previously, it created a temporary directory and then fail when
> FileOutputBuffer renames that file to the destination file (which is
> actually a directory name).
>
>
> https://reviews.llvm.org/D30912
>
> Files:
>   lld/test/ELF/early-exit-for-bad-paths.s
>   llvm/lib/Support/FileOutputBuffer.cpp
>
>
> Index: llvm/lib/Support/FileOutputBuffer.cpp
> ===================================================================
> --- llvm/lib/Support/FileOutputBuffer.cpp
> +++ llvm/lib/Support/FileOutputBuffer.cpp
> @@ -57,6 +57,8 @@
>          // 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;
> Index: lld/test/ELF/early-exit-for-bad-paths.s
> ===================================================================
> --- lld/test/ELF/early-exit-for-bad-paths.s
> +++ lld/test/ELF/early-exit-for-bad-paths.s
> @@ -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
>
>
> Index: llvm/lib/Support/FileOutputBuffer.cpp
> ===================================================================
> --- llvm/lib/Support/FileOutputBuffer.cpp
> +++ llvm/lib/Support/FileOutputBuffer.cpp
> @@ -57,6 +57,8 @@
>          // 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;
> Index: lld/test/ELF/early-exit-for-bad-paths.s
> ===================================================================
> --- lld/test/ELF/early-exit-for-bad-paths.s
> +++ lld/test/ELF/early-exit-for-bad-paths.s
> @@ -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
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list