diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/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.