From 6debf89587f53bb18a2c52a74de13c9d36945822 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 27 May 2010 20:51:54 +0000 Subject: [PATCH] Eliminate some unnessary Path::exists() calls. llvm-svn: 104888 --- llvm/lib/Archive/ArchiveWriter.cpp | 12 ++++-------- llvm/tools/bugpoint/ExtractFunction.cpp | 3 +-- llvm/tools/llvm-link/llvm-link.cpp | 20 +++++++------------- llvm/tools/lto/LTOCodeGenerator.cpp | 6 ++---- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/llvm/lib/Archive/ArchiveWriter.cpp b/llvm/lib/Archive/ArchiveWriter.cpp index 21d4f6566c56..7eeeb59896d3 100644 --- a/llvm/lib/Archive/ArchiveWriter.cpp +++ b/llvm/lib/Archive/ArchiveWriter.cpp @@ -366,8 +366,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress, // Check for errors opening or creating archive file. if (!ArchiveFile.is_open() || ArchiveFile.bad()) { - if (TmpArchive.exists()) - TmpArchive.eraseFromDisk(); + TmpArchive.eraseFromDisk(); if (ErrMsg) *ErrMsg = "Error opening archive file: " + archPath.str(); return true; @@ -387,8 +386,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress, for (MembersList::iterator I = begin(), E = end(); I != E; ++I) { if (writeMember(*I, ArchiveFile, CreateSymbolTable, TruncateNames, Compress, ErrMsg)) { - if (TmpArchive.exists()) - TmpArchive.eraseFromDisk(); + TmpArchive.eraseFromDisk(); ArchiveFile.close(); return true; } @@ -420,8 +418,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress, std::ofstream FinalFile(FinalFilePath.c_str(), io_mode); if (!FinalFile.is_open() || FinalFile.bad()) { - if (TmpArchive.exists()) - TmpArchive.eraseFromDisk(); + TmpArchive.eraseFromDisk(); if (ErrMsg) *ErrMsg = "Error opening archive file: " + FinalFilePath.str(); return true; @@ -438,8 +435,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress, if (foreignST) { if (writeMember(*foreignST, FinalFile, false, false, false, ErrMsg)) { FinalFile.close(); - if (TmpArchive.exists()) - TmpArchive.eraseFromDisk(); + TmpArchive.eraseFromDisk(); return true; } } diff --git a/llvm/tools/bugpoint/ExtractFunction.cpp b/llvm/tools/bugpoint/ExtractFunction.cpp index eaa2c538d963..7808de545ae7 100644 --- a/llvm/tools/bugpoint/ExtractFunction.cpp +++ b/llvm/tools/bugpoint/ExtractFunction.cpp @@ -365,8 +365,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const PI.push_back(getPI(createBlockExtractorPass(EmptyBBs))); Module *Ret = runPassesOn(M, PI, false, 1, &ExtraArg); - if (uniqueFilename.exists()) - uniqueFilename.eraseFromDisk(); // Free disk space + uniqueFilename.eraseFromDisk(); // Free disk space if (Ret == 0) { outs() << "*** Basic Block extraction failed, please report a bug!\n"; diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp index c60e56ae9b6e..f7dad3da5f61 100644 --- a/llvm/tools/llvm-link/llvm-link.cpp +++ b/llvm/tools/llvm-link/llvm-link.cpp @@ -62,20 +62,14 @@ static inline std::auto_ptr LoadFile(const char *argv0, } SMDiagnostic Err; - if (Filename.exists()) { - if (Verbose) errs() << "Loading '" << Filename.c_str() << "'\n"; - Module* Result = 0; - - const std::string &FNStr = Filename.str(); - Result = ParseIRFile(FNStr, Err, Context); - if (Result) return std::auto_ptr(Result); // Load successful! - - if (Verbose) - Err.Print(argv0, errs()); - } else { - errs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n"; - } + if (Verbose) errs() << "Loading '" << Filename.c_str() << "'\n"; + Module* Result = 0; + + const std::string &FNStr = Filename.str(); + Result = ParseIRFile(FNStr, Err, Context); + if (Result) return std::auto_ptr(Result); // Load successful! + Err.Print(argv0, errs()); return std::auto_ptr(); } diff --git a/llvm/tools/lto/LTOCodeGenerator.cpp b/llvm/tools/lto/LTOCodeGenerator.cpp index c4d7e8abe72c..911fddfe1888 100644 --- a/llvm/tools/lto/LTOCodeGenerator.cpp +++ b/llvm/tools/lto/LTOCodeGenerator.cpp @@ -183,16 +183,14 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) genResult = this->generateAssemblyCode(asmFile, errMsg); } if ( genResult ) { - if ( uniqueAsmPath.exists() ) - uniqueAsmPath.eraseFromDisk(); + uniqueAsmPath.eraseFromDisk(); return NULL; } // make unique temp .o file to put generated object file sys::PathWithStatus uniqueObjPath("lto-llvm.o"); if ( uniqueObjPath.createTemporaryFileOnDisk(true, &errMsg) ) { - if ( uniqueAsmPath.exists() ) - uniqueAsmPath.eraseFromDisk(); + uniqueAsmPath.eraseFromDisk(); return NULL; } sys::RemoveFileOnSignal(uniqueObjPath);