[PATCH] D64381: Update libc++ include path detection to use VFS on Linux

2019-07-10 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365682: Update libc++ include path detection to use VFS on 
Linux (authored by juliehockett, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64381?vs=208546=209036#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64381/new/

https://reviews.llvm.org/D64381

Files:
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -865,12 +865,13 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
-static std::string DetectLibcxxIncludePath(StringRef base) {
+static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem ,
+   StringRef base) {
   std::error_code EC;
   int MaxVersion = 0;
   std::string MaxVersionString = "";
-  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
-   LI = LI.increment(EC)) {
+  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
 StringRef VersionText = llvm::sys::path::filename(LI->path());
 int Version;
 if (VersionText[0] == 'v' &&
@@ -888,12 +889,12 @@
   llvm::opt::ArgStringList ) const {
   const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
-  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
   for (const auto  : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;


Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -865,12 +865,13 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
-static std::string DetectLibcxxIncludePath(StringRef base) {
+static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem ,
+   StringRef base) {
   std::error_code EC;
   int MaxVersion = 0;
   std::string MaxVersionString = "";
-  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
-   LI = LI.increment(EC)) {
+  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
 StringRef VersionText = llvm::sys::path::filename(LI->path());
 int Version;
 if (VersionText[0] == 'v' &&
@@ -888,12 +889,12 @@
   llvm::opt::ArgStringList ) const {
   const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
-  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
   for (const auto  : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64381: Update libc++ include path detection to use VFS on Linux

2019-07-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Driver/ToolChains/Linux.cpp:868
 
-static std::string DetectLibcxxIncludePath(StringRef base) {
+static std::string DetectLibcxxIncludePath(StringRef base, 
llvm::vfs::FileSystem& vfs) {
   std::error_code EC;

Nit: can you make `vfs` the first argument?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64381/new/

https://reviews.llvm.org/D64381



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64381: Update libc++ include path detection to use VFS on Linux

2019-07-08 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
juliehockett added reviewers: dlj, phosek.
Herald added a reviewer: EricWF.

The DetectLibcxxIncludePath function had been using 
llvm::sys::fs::directory_iterator, and this updates it to use 
llvm::vfs::directory_iterator.


https://reviews.llvm.org/D64381

Files:
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -865,12 +865,12 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
-static std::string DetectLibcxxIncludePath(StringRef base) {
+static std::string DetectLibcxxIncludePath(StringRef base, 
llvm::vfs::FileSystem& vfs) {
   std::error_code EC;
   int MaxVersion = 0;
   std::string MaxVersionString = "";
-  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
-   LI = LI.increment(EC)) {
+  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
 StringRef VersionText = llvm::sys::path::filename(LI->path());
 int Version;
 if (VersionText[0] == 'v' &&
@@ -888,12 +888,12 @@
   llvm::opt::ArgStringList ) const {
   const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
-  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++", getVFS()),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++", getVFS()),
+  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++", getVFS()) };
   for (const auto  : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -865,12 +865,12 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
-static std::string DetectLibcxxIncludePath(StringRef base) {
+static std::string DetectLibcxxIncludePath(StringRef base, llvm::vfs::FileSystem& vfs) {
   std::error_code EC;
   int MaxVersion = 0;
   std::string MaxVersionString = "";
-  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
-   LI = LI.increment(EC)) {
+  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
 StringRef VersionText = llvm::sys::path::filename(LI->path());
 int Version;
 if (VersionText[0] == 'v' &&
@@ -888,12 +888,12 @@
   llvm::opt::ArgStringList ) const {
   const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
-  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++", getVFS()),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++", getVFS()),
+  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++", getVFS()) };
   for (const auto  : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits