From de8c93b98285d937488a4f8308230e7a405779fe Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 30 Jun 2014 19:56:37 +0000 Subject: [PATCH] Use the newly added FindInEnvPath helper in clang llvm-svn: 212058 --- clang/lib/Driver/Driver.cpp | 31 +------------------------------ clang/lib/Driver/Tools.cpp | 9 ++------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index a18312a..08dcc11 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -939,35 +939,6 @@ void Driver::BuildUniversalActions(const ToolChain &TC, } } -/// \brief Check whether the file referenced by Value exists in the LIB -/// environment variable. -static bool ExistsInLibDir(StringRef Value) { - llvm::Optional OptPath = llvm::sys::Process::GetEnv("LIB"); - if (!OptPath.hasValue()) - return false; - -#ifdef LLVM_ON_WIN32 - const StringRef PathSeparators = ";"; -#else - const StringRef PathSeparators = ":"; -#endif - - SmallVector LibDirs; - llvm::SplitString(OptPath.getValue(), LibDirs, PathSeparators); - - for (const auto &LibDir : LibDirs) { - if (LibDir.empty()) - continue; - - SmallString<128> FilePath(LibDir); - llvm::sys::path::append(FilePath, Value); - if (llvm::sys::fs::exists(Twine(FilePath))) - return true; - } - - return false; -} - /// \brief Check that the file referenced by Value exists. If it doesn't, /// issue a diagnostic and return false. static bool DiagnoseInputExistence(const Driver &D, const DerivedArgList &Args, @@ -991,7 +962,7 @@ static bool DiagnoseInputExistence(const Driver &D, const DerivedArgList &Args, if (llvm::sys::fs::exists(Twine(Path))) return true; - if (D.IsCLMode() && ExistsInLibDir(Value)) + if (D.IsCLMode() && llvm::sys::Process::FindInEnvPath("LIB", Value)) return true; D.Diag(clang::diag::err_drv_no_such_file) << Path.str(); diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 3587bbb..f5d7994 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -7651,14 +7651,9 @@ static std::string FindFallback(const char *FallbackName, if (!OptPath.hasValue()) return FallbackName; -#ifdef LLVM_ON_WIN32 - const StringRef PathSeparators = ";"; -#else - const StringRef PathSeparators = ":"; -#endif - + const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'}; SmallVector PathSegments; - llvm::SplitString(OptPath.getValue(), PathSegments, PathSeparators); + llvm::SplitString(OptPath.getValue(), PathSegments, EnvPathSeparatorStr); for (size_t i = 0, e = PathSegments.size(); i != e; ++i) { const StringRef &PathSegment = PathSegments[i]; -- 2.7.4