diff --git a/README.md b/README.md index b413c4f8..4d408897 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ Nowadays, this file can be generated rather easily using multiple methods: * For Boost-based projects try [commands_to_compilation_database](https://github.com/tee3/commands_to_compilation_database) * For SCons, invoke `compilation_db` tool (requires SCons > 4.0.0) +* For Bazel, try [bazel-compile-commands-extractor](https://github.com/hedronvision/bazel-compile-commands-extractor) * For Microsoft Visual Studio projects try [Clang Power Tools](https://www.clangpowertools.com) ### Invocation diff --git a/src/common/visitor/translation_unit_visitor.cc b/src/common/visitor/translation_unit_visitor.cc index e4d68774..7a2e61fd 100644 --- a/src/common/visitor/translation_unit_visitor.cc +++ b/src/common/visitor/translation_unit_visitor.cc @@ -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()));