[PATCH] D30768: [PATCH][VFS] Ignore broken symlinks in the directory iterator.

Bruno Cardoso Lopes via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 9 11:54:31 PST 2017


bruno added a comment.

Hi Juergen,

Thanks for working on this.



================
Comment at: include/clang/Basic/VirtualFileSystem.h:164
     EC = Impl->increment();
-    if (EC || !Impl->CurrentEntry.isStatusKnown())
+    if (!Impl->CurrentEntry.isStatusKnown())
       Impl.reset(); // Normalize the end iterator to Impl == nullptr.
----------------
I would rather we don't drop checks for `EC`s - it's commonly assumed that whenever they are passed in we wanna check them for errors, can't you just skip the specific case you want to avoid?


================
Comment at: lib/Basic/VirtualFileSystem.cpp:1860
   directory_iterator I = FS->dir_begin(Path, EC);
-  if (!EC && I != directory_iterator()) {
+  if (I != directory_iterator()) {
     State = std::make_shared<IterState>();
----------------
Same here.


================
Comment at: lib/Basic/VirtualFileSystem.cpp:1873
     vfs::directory_iterator I = FS->dir_begin(State->top()->getName(), EC);
-    if (EC)
+    if (EC && EC != std::errc::no_such_file_or_directory)
       return *this;
----------------
Can you add a comment explaining why you are doing it? I would prefer if we reset the `EC` state here than having the callers ignoring `EC` results.


https://reviews.llvm.org/D30768





More information about the cfe-commits mailing list