mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-06 16:24:54 +00:00
fix index error when there is a soft link file as https://github.com/MaskRay/ccls/pull/643
This commit is contained in:
parent
8cf8a3c4a4
commit
88cd914342
@ -25,6 +25,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <filesystem>
|
||||
|
||||
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<std::unique_ptr<IndexFile>> 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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user