Fix issue with conversion op parsing & instantiation type
This commit is contained in:
parent
6e7a8c921c
commit
1c973cb0fa
4 changed files with 29 additions and 16 deletions
|
|
@ -545,6 +545,8 @@ std::unique_ptr<cpp_entity> detail::parse_cpp_member_function(const detail::pars
|
|||
std::move(prefix.semantic_parent));
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
std::unique_ptr<cpp_entity> detail::parse_cpp_conversion_op(const detail::parse_context& context,
|
||||
const CXCursor& cur)
|
||||
{
|
||||
|
|
@ -559,24 +561,27 @@ std::unique_ptr<cpp_entity> detail::parse_cpp_conversion_op(const detail::parse_
|
|||
// heuristic to find arguments tokens
|
||||
// skip forward, skipping inside brackets
|
||||
auto type_start = stream.cur();
|
||||
while (true)
|
||||
auto finished = false;
|
||||
while (!stream.done() && !finished)
|
||||
{
|
||||
if (detail::skip_if(stream, "("))
|
||||
if (stream.peek() == "(")
|
||||
{
|
||||
if (detail::skip_if(stream, ")"))
|
||||
break;
|
||||
if (detail::skip_if(stream, "(") && detail::skip_if(stream, ")"))
|
||||
finished = true;
|
||||
else
|
||||
detail::skip_brackets(stream);
|
||||
}
|
||||
else if (detail::skip_if(stream, "["))
|
||||
else if (stream.peek() == "[")
|
||||
detail::skip_brackets(stream);
|
||||
else if (detail::skip_if(stream, "{"))
|
||||
else if (stream.peek() == "{")
|
||||
detail::skip_brackets(stream);
|
||||
else if (detail::skip_if(stream, "<"))
|
||||
else if (stream.peek() == "<")
|
||||
detail::skip_brackets(stream);
|
||||
else
|
||||
stream.bump();
|
||||
}
|
||||
DEBUG_ASSERT(finished, detail::parse_error_handler{}, cur,
|
||||
"unable to find end of conversion op type");
|
||||
// bump arguments back
|
||||
stream.bump_back();
|
||||
stream.bump_back();
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ detail::token_iterator detail::find_closing_bracket(detail::token_stream stream)
|
|||
|
||||
auto bracket_count = 1;
|
||||
auto paren_count = 0; // internal nested parenthesis
|
||||
while (bracket_count != 0)
|
||||
while (!stream.done() && bracket_count != 0)
|
||||
{
|
||||
auto& cur = stream.get().value();
|
||||
if (paren_count == 0 && cur == open_bracket)
|
||||
|
|
@ -307,7 +307,8 @@ detail::token_iterator detail::find_closing_bracket(detail::token_stream stream)
|
|||
}
|
||||
stream.bump_back();
|
||||
// only check first parameter, token might be ">>"
|
||||
DEBUG_ASSERT(paren_count == 0 && stream.peek().value()[0] == close_bracket[0],
|
||||
DEBUG_ASSERT(bracket_count == 0 && paren_count == 0
|
||||
&& stream.peek().value()[0] == close_bracket[0],
|
||||
parse_error_handler{}, stream.cursor(),
|
||||
"find_closing_bracket() internal parse error");
|
||||
return stream.cur();
|
||||
|
|
|
|||
|
|
@ -585,10 +585,14 @@ namespace
|
|||
return cpp_builtin_type::build(cpp_nullptr);
|
||||
});
|
||||
|
||||
case CXType_Elaborated:
|
||||
if (auto itype = try_parse_instantiation_type(context, cur, type))
|
||||
// elaborated types can be instantiation types
|
||||
return itype;
|
||||
// fallthrough
|
||||
case CXType_Record:
|
||||
case CXType_Enum:
|
||||
case CXType_Typedef:
|
||||
case CXType_Elaborated:
|
||||
return make_leave_type(type, [&](std::string&& spelling) {
|
||||
auto decl = clang_getTypeDeclaration(type);
|
||||
if (remove_prefix(spelling, "(anonymous"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue