From fa3e8979a53217f19c06b7623a70ef58c902e4fb Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Sat, 28 Mar 2015 00:34:09 +0000 Subject: [PATCH] ELF: make code concise using "using". llvm-svn: 233458 --- .../ReaderWriter/ELF/ELFLinkingContext.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp index 4d5c9a8046e9..03332399e0ad 100644 --- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp @@ -25,6 +25,9 @@ #include #endif +using llvm::sys::fs::exists; +using llvm::sys::path::is_absolute; + namespace lld { class CommandLineUndefinedAtom : public SimpleUndefinedAtom { @@ -122,7 +125,7 @@ ErrorOr ELFLinkingContext::searchLibrary(StringRef libName) const { llvm::sys::path::append(path, hasColonPrefix ? libName.drop_front() : Twine("lib", libName) + ".so"); - if (llvm::sys::fs::exists(path.str())) + if (exists(path.str())) return StringRef(*new (_allocator) std::string(path.str())); } // Search for static libraries too @@ -130,10 +133,10 @@ ErrorOr ELFLinkingContext::searchLibrary(StringRef libName) const { llvm::sys::path::append(path, hasColonPrefix ? libName.drop_front() : Twine("lib", libName) + ".a"); - if (llvm::sys::fs::exists(path.str())) + if (exists(path.str())) return StringRef(*new (_allocator) std::string(path.str())); } - if (hasColonPrefix && llvm::sys::fs::exists(libName.drop_front())) + if (hasColonPrefix && exists(libName.drop_front())) return libName.drop_front(); return make_error_code(llvm::errc::no_such_file_or_directory); @@ -142,21 +145,22 @@ ErrorOr ELFLinkingContext::searchLibrary(StringRef libName) const { ErrorOr ELFLinkingContext::searchFile(StringRef fileName, bool isSysRooted) const { SmallString<128> path; - if (llvm::sys::path::is_absolute(fileName) && isSysRooted) { + if (is_absolute(fileName) && isSysRooted) { path.assign(_sysrootPath); path.append(fileName); - if (llvm::sys::fs::exists(path.str())) + if (exists(path.str())) return StringRef(*new (_allocator) std::string(path.str())); - } else if (llvm::sys::fs::exists(fileName)) + } else if (exists(fileName)) { return fileName; + } - if (llvm::sys::path::is_absolute(fileName)) + if (is_absolute(fileName)) return make_error_code(llvm::errc::no_such_file_or_directory); for (StringRef dir : _inputSearchPaths) { buildSearchPath(path, dir, _sysrootPath); llvm::sys::path::append(path, fileName); - if (llvm::sys::fs::exists(path.str())) + if (exists(path.str())) return StringRef(*new (_allocator) std::string(path.str())); } return make_error_code(llvm::errc::no_such_file_or_directory); -- 2.34.1