Fixed relative lambda names in MSVC
This commit is contained in:
@@ -1143,20 +1143,27 @@ void translation_unit_visitor::process_function_parameter(
|
|||||||
void translation_unit_visitor::ensure_lambda_type_is_relative(
|
void translation_unit_visitor::ensure_lambda_type_is_relative(
|
||||||
std::string ¶meter_type) const
|
std::string ¶meter_type) const
|
||||||
{
|
{
|
||||||
std::string lambda_prefix{"(lambda at /"};
|
#ifdef _MSC_VER
|
||||||
|
auto root_name = fmt::format(
|
||||||
|
"{}\\", std::filesystem::current_path().root_name().string());
|
||||||
|
#else
|
||||||
|
auto root_name = "/";
|
||||||
|
#endif
|
||||||
|
std::string lambda_prefix{fmt::format("(lambda at {}", root_name)};
|
||||||
|
|
||||||
while (parameter_type.find(lambda_prefix) != std::string::npos) {
|
while (parameter_type.find(lambda_prefix) != std::string::npos) {
|
||||||
auto lambda_begin = parameter_type.find(lambda_prefix);
|
auto lambda_begin = parameter_type.find(lambda_prefix);
|
||||||
|
|
||||||
auto absolute_lambda_path_end = parameter_type.find(':', lambda_begin);
|
auto absolute_lambda_path_end =
|
||||||
|
parameter_type.find(':', lambda_begin + lambda_prefix.size());
|
||||||
auto absolute_lambda_path =
|
auto absolute_lambda_path =
|
||||||
parameter_type.substr(lambda_begin + lambda_prefix.size() - 1,
|
parameter_type.substr(lambda_begin + lambda_prefix.size() - 1,
|
||||||
absolute_lambda_path_end -
|
absolute_lambda_path_end -
|
||||||
(lambda_begin + lambda_prefix.size() - 1));
|
(lambda_begin + lambda_prefix.size() - 1));
|
||||||
|
|
||||||
auto relative_lambda_path = std::filesystem::relative(
|
auto relative_lambda_path = util::path_to_url(std::filesystem::relative(
|
||||||
absolute_lambda_path, config().relative_to())
|
absolute_lambda_path, config().relative_to())
|
||||||
.string();
|
.string());
|
||||||
|
|
||||||
parameter_type = fmt::format("{}(lambda at {}{}",
|
parameter_type = fmt::format("{}(lambda at {}{}",
|
||||||
parameter_type.substr(0, lambda_begin), relative_lambda_path,
|
parameter_type.substr(0, lambda_begin), relative_lambda_path,
|
||||||
|
|||||||
@@ -255,6 +255,13 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const package_diagram &c);
|
|||||||
|
|
||||||
YAML::Emitter &operator<<(YAML::Emitter &out, const layout_hint &c);
|
YAML::Emitter &operator<<(YAML::Emitter &out, const layout_hint &c);
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
YAML::Emitter &operator<<(YAML::Emitter &out, const std::filesystem::path &p);
|
||||||
|
|
||||||
|
YAML::Emitter &operator<<(
|
||||||
|
YAML::Emitter &out, const std::vector<std::filesystem::path> &p);
|
||||||
|
#endif
|
||||||
|
|
||||||
YAML::Emitter &operator<<(YAML::Emitter &out, const source_location &sc);
|
YAML::Emitter &operator<<(YAML::Emitter &out, const source_location &sc);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -262,7 +269,10 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const option<T> &o)
|
|||||||
{
|
{
|
||||||
if (o.has_value) {
|
if (o.has_value) {
|
||||||
out << YAML::Key << o.name;
|
out << YAML::Key << o.name;
|
||||||
out << YAML::Value << o.value;
|
if constexpr (std::is_same_v<T, std::filesystem::path>)
|
||||||
|
out << YAML::Value << o.value.string();
|
||||||
|
else
|
||||||
|
out << YAML::Value << o.value;
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,6 +138,24 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const comment_parser_t &cp)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
YAML::Emitter &operator<<(YAML::Emitter &out, const std::filesystem::path &p)
|
||||||
|
{
|
||||||
|
out << p.string();
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
YAML::Emitter &operator<<(
|
||||||
|
YAML::Emitter &out, const std::vector<std::filesystem::path> &paths)
|
||||||
|
{
|
||||||
|
out << YAML::BeginSeq;
|
||||||
|
for (const auto &p : paths)
|
||||||
|
out << p;
|
||||||
|
out << YAML::EndSeq;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
YAML::Emitter &operator<<(YAML::Emitter &out, const layout_hint &c)
|
YAML::Emitter &operator<<(YAML::Emitter &out, const layout_hint &c)
|
||||||
{
|
{
|
||||||
out << YAML::BeginMap;
|
out << YAML::BeginMap;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ decorator_toks decorator::tokenize(const std::string &label, std::string_view c)
|
|||||||
decorator_toks res;
|
decorator_toks res;
|
||||||
res.label = label;
|
res.label = label;
|
||||||
size_t pos{};
|
size_t pos{};
|
||||||
const auto *it = c.begin();
|
std::string_view::const_iterator it = c.begin();
|
||||||
std::advance(it, label.size());
|
std::advance(it, label.size());
|
||||||
|
|
||||||
if (*it == ':') {
|
if (*it == ':') {
|
||||||
|
|||||||
@@ -264,11 +264,12 @@ int main(int argc, const char *argv[])
|
|||||||
//
|
//
|
||||||
if (compilation_database_dir) {
|
if (compilation_database_dir) {
|
||||||
config.compilation_database_dir.set(
|
config.compilation_database_dir.set(
|
||||||
util::ensure_path_is_absolute(compilation_database_dir.value()));
|
util::ensure_path_is_absolute(compilation_database_dir.value())
|
||||||
|
.string());
|
||||||
}
|
}
|
||||||
if (output_directory) {
|
if (output_directory) {
|
||||||
config.output_directory.set(
|
config.output_directory.set(
|
||||||
util::ensure_path_is_absolute(output_directory.value()));
|
util::ensure_path_is_absolute(output_directory.value()).string());
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Loading compilation database from {} directory",
|
LOG_INFO("Loading compilation database from {} directory",
|
||||||
|
|||||||
@@ -232,12 +232,20 @@ TEST_CASE("Test ensure_path_is_absolute", "[unit-test]")
|
|||||||
{
|
{
|
||||||
using namespace clanguml::util;
|
using namespace clanguml::util;
|
||||||
|
|
||||||
CHECK(ensure_path_is_absolute("a/b/c", "/tmp").string() == "/tmp/a/b/c");
|
using std::filesystem::path;
|
||||||
CHECK(ensure_path_is_absolute("/a/b/c", "/tmp").string() == "/a/b/c");
|
|
||||||
CHECK(ensure_path_is_absolute("", "/tmp").string() == "/tmp/");
|
CHECK(ensure_path_is_absolute("a/b/c", "/tmp").string() ==
|
||||||
CHECK(ensure_path_is_absolute(".", "/tmp").string() == "/tmp/");
|
path{"/tmp/a/b/c"}.make_preferred());
|
||||||
CHECK(ensure_path_is_absolute("..", "/tmp").string() == "/");
|
CHECK(ensure_path_is_absolute("/a/b/c", "/tmp").string() ==
|
||||||
CHECK(ensure_path_is_absolute("/", "/tmp").string() == "/");
|
path{"/a/b/c"}.make_preferred());
|
||||||
|
CHECK(ensure_path_is_absolute("", "/tmp").string() ==
|
||||||
|
path{"/tmp/"}.make_preferred());
|
||||||
|
CHECK(ensure_path_is_absolute(".", "/tmp").string() ==
|
||||||
|
path{"/tmp/"}.make_preferred());
|
||||||
|
CHECK(ensure_path_is_absolute("..", "/tmp").string() ==
|
||||||
|
path{"/"}.make_preferred());
|
||||||
|
CHECK(ensure_path_is_absolute("/", "/tmp").string() ==
|
||||||
|
path{"/"}.make_preferred());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Test hash_seed", "[unit-test]")
|
TEST_CASE("Test hash_seed", "[unit-test]")
|
||||||
|
|||||||
Reference in New Issue
Block a user