r212058 - Use the newly added FindInEnvPath helper in clang
Ehsan Akhgari
ehsan.akhgari at gmail.com
Mon Jun 30 12:56:38 PDT 2014
Author: ehsan
Date: Mon Jun 30 14:56:37 2014
New Revision: 212058
URL: http://llvm.org/viewvc/llvm-project?rev=212058&view=rev
Log:
Use the newly added FindInEnvPath helper in clang
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=212058&r1=212057&r2=212058&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jun 30 14:56:37 2014
@@ -939,35 +939,6 @@ void Driver::BuildUniversalActions(const
}
}
-/// \brief Check whether the file referenced by Value exists in the LIB
-/// environment variable.
-static bool ExistsInLibDir(StringRef Value) {
- llvm::Optional<std::string> OptPath = llvm::sys::Process::GetEnv("LIB");
- if (!OptPath.hasValue())
- return false;
-
-#ifdef LLVM_ON_WIN32
- const StringRef PathSeparators = ";";
-#else
- const StringRef PathSeparators = ":";
-#endif
-
- SmallVector<StringRef, 8> 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
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();
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=212058&r1=212057&r2=212058&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jun 30 14:56:37 2014
@@ -7651,14 +7651,9 @@ static std::string FindFallback(const ch
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<StringRef, 8> 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];
More information about the cfe-commits
mailing list