Fix handling of compile_commands.json files with relative include paths (Fixes #189)

This commit is contained in:
Bartek Kryza
2023-10-12 17:08:25 +02:00
parent 8865a42ff0
commit 26abb71b4c
2 changed files with 7 additions and 0 deletions

View File

@@ -123,6 +123,12 @@ void translation_unit_visitor::set_source_location(
}
}
if (std::filesystem::path file_path{file}; !file_path.is_absolute()) {
file_path =
std::filesystem::canonical(std::filesystem::absolute(file_path));
file = file_path.string();
}
element.set_file(file);
element.set_file_relative(util::path_to_url(
std::filesystem::relative(element.file(), relative_to_path_).string()));