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

Julie Hockett via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 17:15:52 PDT 2019


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 &CC1Args) 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 &IncludePath : LibCXXIncludePathCandidates) {
     if (IncludePath.empty() || !getVFS().exists(IncludePath))
       continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64381.208546.patch
Type: text/x-patch
Size: 1855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190709/53804f22/attachment.bin>


More information about the cfe-commits mailing list