Skip to content

Commit 6debf89

Browse files
author
Dan Gohman
committed
Eliminate some unnessary Path::exists() calls.
llvm-svn: 104888
1 parent caf0ab6 commit 6debf89

File tree

4 files changed

+14
-27
lines changed

4 files changed

+14
-27
lines changed

llvm/lib/Archive/ArchiveWriter.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
366366

367367
// Check for errors opening or creating archive file.
368368
if (!ArchiveFile.is_open() || ArchiveFile.bad()) {
369-
if (TmpArchive.exists())
370-
TmpArchive.eraseFromDisk();
369+
TmpArchive.eraseFromDisk();
371370
if (ErrMsg)
372371
*ErrMsg = "Error opening archive file: " + archPath.str();
373372
return true;
@@ -387,8 +386,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
387386
for (MembersList::iterator I = begin(), E = end(); I != E; ++I) {
388387
if (writeMember(*I, ArchiveFile, CreateSymbolTable,
389388
TruncateNames, Compress, ErrMsg)) {
390-
if (TmpArchive.exists())
391-
TmpArchive.eraseFromDisk();
389+
TmpArchive.eraseFromDisk();
392390
ArchiveFile.close();
393391
return true;
394392
}
@@ -420,8 +418,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
420418

421419
std::ofstream FinalFile(FinalFilePath.c_str(), io_mode);
422420
if (!FinalFile.is_open() || FinalFile.bad()) {
423-
if (TmpArchive.exists())
424-
TmpArchive.eraseFromDisk();
421+
TmpArchive.eraseFromDisk();
425422
if (ErrMsg)
426423
*ErrMsg = "Error opening archive file: " + FinalFilePath.str();
427424
return true;
@@ -438,8 +435,7 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
438435
if (foreignST) {
439436
if (writeMember(*foreignST, FinalFile, false, false, false, ErrMsg)) {
440437
FinalFile.close();
441-
if (TmpArchive.exists())
442-
TmpArchive.eraseFromDisk();
438+
TmpArchive.eraseFromDisk();
443439
return true;
444440
}
445441
}

llvm/tools/bugpoint/ExtractFunction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
365365
PI.push_back(getPI(createBlockExtractorPass(EmptyBBs)));
366366
Module *Ret = runPassesOn(M, PI, false, 1, &ExtraArg);
367367

368-
if (uniqueFilename.exists())
369-
uniqueFilename.eraseFromDisk(); // Free disk space
368+
uniqueFilename.eraseFromDisk(); // Free disk space
370369

371370
if (Ret == 0) {
372371
outs() << "*** Basic Block extraction failed, please report a bug!\n";

llvm/tools/llvm-link/llvm-link.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,14 @@ static inline std::auto_ptr<Module> LoadFile(const char *argv0,
6262
}
6363

6464
SMDiagnostic Err;
65-
if (Filename.exists()) {
66-
if (Verbose) errs() << "Loading '" << Filename.c_str() << "'\n";
67-
Module* Result = 0;
68-
69-
const std::string &FNStr = Filename.str();
70-
Result = ParseIRFile(FNStr, Err, Context);
71-
if (Result) return std::auto_ptr<Module>(Result); // Load successful!
72-
73-
if (Verbose)
74-
Err.Print(argv0, errs());
75-
} else {
76-
errs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n";
77-
}
65+
if (Verbose) errs() << "Loading '" << Filename.c_str() << "'\n";
66+
Module* Result = 0;
67+
68+
const std::string &FNStr = Filename.str();
69+
Result = ParseIRFile(FNStr, Err, Context);
70+
if (Result) return std::auto_ptr<Module>(Result); // Load successful!
7871

72+
Err.Print(argv0, errs());
7973
return std::auto_ptr<Module>();
8074
}
8175

llvm/tools/lto/LTOCodeGenerator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,14 @@ const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg)
183183
genResult = this->generateAssemblyCode(asmFile, errMsg);
184184
}
185185
if ( genResult ) {
186-
if ( uniqueAsmPath.exists() )
187-
uniqueAsmPath.eraseFromDisk();
186+
uniqueAsmPath.eraseFromDisk();
188187
return NULL;
189188
}
190189

191190
// make unique temp .o file to put generated object file
192191
sys::PathWithStatus uniqueObjPath("lto-llvm.o");
193192
if ( uniqueObjPath.createTemporaryFileOnDisk(true, &errMsg) ) {
194-
if ( uniqueAsmPath.exists() )
195-
uniqueAsmPath.eraseFromDisk();
193+
uniqueAsmPath.eraseFromDisk();
196194
return NULL;
197195
}
198196
sys::RemoveFileOnSignal(uniqueObjPath);

0 commit comments

Comments
 (0)