dgoldman created this revision. dgoldman added a reviewer: sammccall. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Previously any symlinks would be ignored since the directory traversal doesn't follow them. With this change we now follow symlinks (via a `stat` call in order to figure out the target type of the symlink if it is valid). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D74790 Files: clang/lib/Sema/SemaCodeComplete.cpp Index: clang/lib/Sema/SemaCodeComplete.cpp =================================================================== --- clang/lib/Sema/SemaCodeComplete.cpp +++ clang/lib/Sema/SemaCodeComplete.cpp @@ -8776,7 +8776,19 @@ if (++Count == 2500) // If we happen to hit a huge directory, break; // bail out early so we're not too slow. StringRef Filename = llvm::sys::path::filename(It->path()); - switch (It->type()) { + + // We need to manually resolve symlinks since the directory_iterator + // doesn't do it for us. Alternatively we could use a heuristic such as + // file extension, but this should be okay as long as there aren't many + // symlinks. + auto Type = It->type(); + if (Type == llvm::sys::fs::file_type::symlink_file) { + auto FileStatus = FS.status(It->path()); + if (FileStatus) { + Type = FileStatus->getType(); + } + } + switch (Type) { case llvm::sys::fs::file_type::directory_file: // All entries in a framework directory must have a ".framework" suffix, // but the suffix does not appear in the source code's include/import.
Index: clang/lib/Sema/SemaCodeComplete.cpp =================================================================== --- clang/lib/Sema/SemaCodeComplete.cpp +++ clang/lib/Sema/SemaCodeComplete.cpp @@ -8776,7 +8776,19 @@ if (++Count == 2500) // If we happen to hit a huge directory, break; // bail out early so we're not too slow. StringRef Filename = llvm::sys::path::filename(It->path()); - switch (It->type()) { + + // We need to manually resolve symlinks since the directory_iterator + // doesn't do it for us. Alternatively we could use a heuristic such as + // file extension, but this should be okay as long as there aren't many + // symlinks. + auto Type = It->type(); + if (Type == llvm::sys::fs::file_type::symlink_file) { + auto FileStatus = FS.status(It->path()); + if (FileStatus) { + Type = FileStatus->getType(); + } + } + switch (Type) { case llvm::sys::fs::file_type::directory_file: // All entries in a framework directory must have a ".framework" suffix, // but the suffix does not appear in the source code's include/import.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits