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)) {
--- /dev/null
+// 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; }