Simplify remove, create_directory and create_directories.
[oota-llvm.git] / unittests / Transforms / DebugIR / DebugIR.cpp
index a0916a21d21e2b45e1e48aef3d77a1579137a50d..affdd762ba62581fa2b47027b4901406cf3e96c2 100644 (file)
@@ -55,9 +55,10 @@ void insertCUDescriptor(Module *M, StringRef File, StringRef Dir,
 /// Attempts to remove file at Path and returns true if it existed, or false if
 /// it did not.
 bool removeIfExists(StringRef Path) {
-  bool existed = false;
-  sys::fs::remove(Path, existed);
-  return existed;
+  // This is an approximation, on error we don't know in general if the file
+  // existed or not.
+  llvm::error_code EC = sys::fs::remove(Path, false);
+  return EC != llvm::errc::no_such_file_or_directory;
 }
 
 char * current_dir() {