Prevent infinite recursion during alias resolution #18
This commit is contained in:
@@ -115,7 +115,12 @@ translation_unit_context::get_type_alias_final(const cppast::cpp_type &t) const
|
||||
cx::util::full_name(cppast::remove_cv(t), entity_index_, false);
|
||||
|
||||
if (has_type_alias(type_full_name)) {
|
||||
return get_type_alias_final(alias_index_.at(type_full_name).get());
|
||||
const auto &alias_type = alias_index_.at(type_full_name).get();
|
||||
// Prevent infinite recursion
|
||||
if (type_full_name !=
|
||||
cx::util::full_name(
|
||||
cppast::remove_cv(alias_type), entity_index_, false))
|
||||
return get_type_alias_final(alias_type);
|
||||
}
|
||||
|
||||
return type_safe::ref(t);
|
||||
|
||||
@@ -1349,8 +1349,11 @@ bool translation_unit_visitor::find_relationships_in_user_defined_type(
|
||||
if (ctx.has_type_alias(fn)) {
|
||||
LOG_DBG("Find relationship in alias of {} | {}", fn,
|
||||
cppast::to_string(ctx.get_type_alias(fn).get()));
|
||||
found = find_relationships(
|
||||
ctx.get_type_alias(fn).get(), relationships, relationship_type);
|
||||
if (cppast::to_string(t_) == fn)
|
||||
found = true;
|
||||
else
|
||||
found = find_relationships(
|
||||
ctx.get_type_alias(fn).get(), relationships, relationship_type);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,10 @@ std::string ns(const cppast::cpp_entity &e)
|
||||
}
|
||||
it = it.value().parent();
|
||||
}
|
||||
|
||||
if (res.empty())
|
||||
return "";
|
||||
|
||||
std::reverse(res.begin(), res.end());
|
||||
|
||||
return fmt::format("{}", fmt::join(res, "::"));
|
||||
|
||||
Reference in New Issue
Block a user