From 88cd914342a9714830a2c252eab900a32bcb452b Mon Sep 17 00:00:00 2001 From: lenajin Date: Sun, 28 Jun 2020 11:26:33 +0800 Subject: [PATCH] fix index error when there is a soft link file as https://github.com/MaskRay/ccls/pull/643 --- src/indexer.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/indexer.cc b/src/indexer.cc index 7b7c1480..e154da62 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -25,6 +25,7 @@ #include #include #include +#include using namespace clang; @@ -1355,6 +1356,11 @@ index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs, return {}; } + std::string abs_main; + if (std::filesystem::exists(main)) { + abs_main = std::filesystem::canonical(main); + } + std::vector> result; for (auto &it : param.uid2file) { if (!it.second.db) @@ -1392,6 +1398,13 @@ index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs, entry->dependencies[llvm::CachedHashStringRef(intern(path))] = file.mtime; } + std::string abs_entry; + if (std::filesystem::exists(entry->path)) { + abs_entry = std::filesystem::canonical(entry->path); + if (abs_entry == abs_main){ + entry->path = main; + } + } result.push_back(std::move(entry)); }