Fix manual parsing of Windows source location paths (#217)

This commit is contained in:
Bartek Kryza
2023-12-14 19:43:37 +01:00
parent 7be848b8a1
commit 4da14a32d7
3 changed files with 57 additions and 2 deletions

View File

@@ -836,12 +836,23 @@ bool parse_source_location(const std::string &location_str, std::string &file,
if (tokens.size() < 3)
return false;
if (tokens.size() == 4) {
// Handle Windows paths
decltype(tokens) tmp_tokens{};
tmp_tokens.emplace_back(
fmt::format("{}:{}", tokens.at(0), tokens.at(1)));
tmp_tokens.emplace_back(tokens.at(2));
tmp_tokens.emplace_back(tokens.at(3));
tokens = std::move(tmp_tokens);
}
file = tokens.at(0);
try {
line = std::stoi(tokens.at(1));
}
catch (std::invalid_argument &e) {
line = 0;
return false;
}
try {

View File

@@ -141,7 +141,7 @@ void translation_unit_visitor::set_source_location(
file_path = fs::absolute(file_path);
}
file_path = fs::canonical(file_path);
file_path = fs::weakly_canonical(file_path);
file = file_path.string();