Addressed the review comment.
http://reviews.llvm.org/D4202
Files:
lib/Driver/Driver.cpp
lib/Driver/Tools.cpp
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -929,35 +929,6 @@
}
}
-/// \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,
@@ -981,7 +952,7 @@
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();
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7536,14 +7536,9 @@
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];
Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -929,35 +929,6 @@
}
}
-/// \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,
@@ -981,7 +952,7 @@
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();
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7536,14 +7536,9 @@
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];
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits