Improve function scope parsing
This commit is contained in:
parent
c07f80ccf3
commit
7a9f6fdfac
5 changed files with 126 additions and 66 deletions
|
|
@ -91,6 +91,19 @@ void detail::comment_context::match(cpp_entity& e, unsigned line) const
|
|||
e.set_comment(std::move(cur_++->comment));
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
bool is_friend(const CXCursor& parent_cur)
|
||||
{
|
||||
#if CPPAST_CINDEX_HAS_FRIEND
|
||||
return clang_getCursorKind(parent_cur) == CXCursor_FriendDecl;
|
||||
#else
|
||||
(void)parent_cur;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& context,
|
||||
const CXCursor& cur,
|
||||
const CXCursor& parent_cur) try
|
||||
|
|
@ -145,25 +158,29 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
|
|||
return parse_cpp_member_variable(context, cur);
|
||||
|
||||
case CXCursor_FunctionDecl:
|
||||
if (auto tfunc = try_parse_cpp_function_template_specialization(context, cur))
|
||||
if (auto tfunc =
|
||||
try_parse_cpp_function_template_specialization(context, cur, is_friend(parent_cur)))
|
||||
return tfunc;
|
||||
return parse_cpp_function(context, cur);
|
||||
return parse_cpp_function(context, cur, is_friend(parent_cur));
|
||||
case CXCursor_CXXMethod:
|
||||
if (auto tfunc = try_parse_cpp_function_template_specialization(context, cur))
|
||||
if (auto tfunc =
|
||||
try_parse_cpp_function_template_specialization(context, cur, is_friend(parent_cur)))
|
||||
return tfunc;
|
||||
else if (auto func = try_parse_static_cpp_function(context, cur))
|
||||
return func;
|
||||
return parse_cpp_member_function(context, cur);
|
||||
return parse_cpp_member_function(context, cur, is_friend(parent_cur));
|
||||
case CXCursor_ConversionFunction:
|
||||
if (auto tfunc = try_parse_cpp_function_template_specialization(context, cur))
|
||||
if (auto tfunc =
|
||||
try_parse_cpp_function_template_specialization(context, cur, is_friend(parent_cur)))
|
||||
return tfunc;
|
||||
return parse_cpp_conversion_op(context, cur);
|
||||
return parse_cpp_conversion_op(context, cur, is_friend(parent_cur));
|
||||
case CXCursor_Constructor:
|
||||
if (auto tfunc = try_parse_cpp_function_template_specialization(context, cur))
|
||||
if (auto tfunc =
|
||||
try_parse_cpp_function_template_specialization(context, cur, is_friend(parent_cur)))
|
||||
return tfunc;
|
||||
return parse_cpp_constructor(context, cur);
|
||||
return parse_cpp_constructor(context, cur, is_friend(parent_cur));
|
||||
case CXCursor_Destructor:
|
||||
return parse_cpp_destructor(context, cur);
|
||||
return parse_cpp_destructor(context, cur, is_friend(parent_cur));
|
||||
|
||||
#if CPPAST_CINDEX_HAS_FRIEND
|
||||
case CXCursor_FriendDecl:
|
||||
|
|
@ -173,7 +190,7 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
|
|||
case CXCursor_TypeAliasTemplateDecl:
|
||||
return parse_cpp_alias_template(context, cur);
|
||||
case CXCursor_FunctionTemplate:
|
||||
return parse_cpp_function_template(context, cur);
|
||||
return parse_cpp_function_template(context, cur, is_friend(parent_cur));
|
||||
case CXCursor_ClassTemplate:
|
||||
return parse_cpp_class_template(context, cur);
|
||||
case CXCursor_ClassTemplatePartialSpecialization:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue