[PATCH] D52648: [Support] Listing a directory containing dangling symlinks is not an error.

Sam McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 28 09:43:57 PDT 2018


sammccall added inline comments.


================
Comment at: include/llvm/Support/FileSystem.h:1220-1221
   }
   // Other members as required by
   // C++ Std, 24.1.1 Input iterators [input.iterators]
 };
----------------
Dor1s wrote:
> is this comment still relevant?
In both `directory_iterator` and `recursive_directory_iterator` I can't tell if this comment refers to the **above** members or is a placeholder for future expansion. But it's been this way for at least 8 years. I'll remove them.


================
Comment at: include/llvm/Support/FileSystem.h:1263
+        if (status)
+          type = status->type();
+        // Otherwise broken symlink, and we'll continue.
----------------
Dor1s wrote:
> Can this `status` be different from the value obtained on line 1259?
Line 1259 gets the type (not status) from the directory listing, which will be `symlink_file` if the thing in the dir is a symlink.

The `stat()` is a resolving stat on the symlink (notice here type is `symlink_file` and `Follow` is true), so the new type is of the symlink *target*. This allows us to traverse into it if it's a directory.


Repository:
  rL LLVM

https://reviews.llvm.org/D52648





More information about the llvm-commits mailing list