From 5c20ac0134a0f9eb806f9304ef769c75954efaf7 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 23 Feb 2014 13:56:14 +0000 Subject: Simplify remove, create_directory and create_directories. Before this patch they would take an boolean argument to say if the path already existed. This was redundant with the returned error_code which is able to represent that. This allowed for callers to incorrectly check only the existed flag instead of first checking the error code. Instead, pass in a boolean flag to say if the previous (non-)existence should be an error or not. Callers of the of the old simple versions are not affected. They still ignore the previous (non-)existence as they did before. llvm-svn: 201979 --- llvm/unittests/Transforms/DebugIR/DebugIR.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/unittests/Transforms') diff --git a/llvm/unittests/Transforms/DebugIR/DebugIR.cpp b/llvm/unittests/Transforms/DebugIR/DebugIR.cpp index a0916a21d21..affdd762ba6 100644 --- a/llvm/unittests/Transforms/DebugIR/DebugIR.cpp +++ b/llvm/unittests/Transforms/DebugIR/DebugIR.cpp @@ -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() { -- cgit v1.2.3