From 582b2ab0dd9a81d4f91ff096320c2b46750f4b3a Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 23 Jan 2013 01:08:23 +0000 Subject: [PATCH] [Driver] Don't remove non-regular files that were outputs. llvm-svn: 173215 --- clang/lib/Driver/Compilation.cpp | 6 +++--- clang/test/Driver/output-file-is-dir.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 clang/test/Driver/output-file-is-dir.c diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index f550a27..9c7100f 100644 --- a/clang/lib/Driver/Compilation.cpp +++ b/clang/lib/Driver/Compilation.cpp @@ -210,9 +210,9 @@ bool Compilation::CleanupFileList(const ArgStringList &Files, std::string Error; // Don't try to remove files which we don't have write access to (but may be - // able to remove). Underlying tools may have intentionally not overwritten - // them. - if (!P.canWrite()) + // able to remove), or non-regular files. Underlying tools may have + // intentionally not overwritten them. + if (!P.canWrite() || !P.isRegularFile()) continue; if (P.eraseFromDisk(false, &Error)) { diff --git a/clang/test/Driver/output-file-is-dir.c b/clang/test/Driver/output-file-is-dir.c new file mode 100644 index 0000000..50f4cf9 --- /dev/null +++ b/clang/test/Driver/output-file-is-dir.c @@ -0,0 +1,6 @@ +// RUN: rm -rf %t.dir +// RUN: mkdir -p %t.dir/a.out +// RUN: cd %t.dir && not %clang %s +// RUN: test -d %t.dir/a.out + +int main() { return 0; } -- 2.7.4