llvm-project/clang/test/Frontend/output-paths.c
Steven Wu 493766e068 Frontend: Respect -working-directory when checking if output files can be written
Call `FixupRelativePath` when opening output files to ensure that
`-working-directory` is used when checking up front for write failures,
not just when finalizing the files at the end. This also moves the
temporary file into the same directory as the output file.

Reviewed By: benlangmuir

Differential Revision: https://reviews.llvm.org/D95497
2022-09-09 08:57:12 -07:00

14 lines
597 B
C

// RUN: not %clang_cc1 -emit-llvm -o %t.doesnotexist/somename %s 2> %t
// RUN: FileCheck -check-prefix=OUTPUTFAIL -DMSG=%errc_ENOENT -input-file=%t %s
// OUTPUTFAIL: error: unable to open output file '{{.*}}doesnotexist{{.}}somename': '[[MSG]]'
// Check that -working-directory is respected when diagnosing output failures.
//
// RUN: rm -rf %t.d && mkdir -p %t.d/%basename_t-inner.d
// RUN: %clang_cc1 -emit-llvm -working-directory %t.d -E -o %basename_t-inner.d/somename %s -verify
// expected-no-diagnostics
// RUN: %clang_cc1 -working-directory %t.d -E %s -o - | FileCheck %s
// CHECK: # 1