Workaround weird issue with broken children of function definition
This commit is contained in:
parent
2ce5ddc295
commit
099ff00908
2 changed files with 19 additions and 3 deletions
|
|
@ -333,6 +333,8 @@ namespace
|
|||
else
|
||||
stream.bump();
|
||||
}
|
||||
if (stream.peek() == "{" || stream.peek() == ":" || stream.peek() == "try")
|
||||
result.body_kind = cpp_function_definition;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -356,6 +358,9 @@ namespace
|
|||
|
||||
if (detail::skip_if(stream, "="))
|
||||
parse_body(stream, result, allow_virtual);
|
||||
else if (detail::skip_if(stream, "{") || detail::skip_if(stream, ":")
|
||||
|| detail::skip_if(stream, "try"))
|
||||
result.body_kind = cpp_function_definition;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ namespace
|
|||
auto kind = clang_getCursorKind(cur);
|
||||
if (cursor_is_function(kind) || cursor_is_function(clang_getTemplateCursorKind(cur)))
|
||||
{
|
||||
auto range_shrunk = false;
|
||||
auto is_definition = false;
|
||||
|
||||
// if a function we need to remove the body
|
||||
// it does not need to be parsed
|
||||
|
|
@ -105,11 +105,22 @@ namespace
|
|||
{
|
||||
auto child_extent = clang_getCursorExtent(child);
|
||||
end = clang_getRangeStart(child_extent);
|
||||
range_shrunk = true;
|
||||
is_definition = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!range_shrunk && !token_after_is(tu, file, cur, end, ";"))
|
||||
if (!is_definition)
|
||||
{
|
||||
// i have no idea why this is necessary
|
||||
is_definition = token_after_is(tu, file, cur, end, "{")
|
||||
|| token_after_is(tu, file, cur, end, "try")
|
||||
|| token_after_is(tu, file, cur, end, ":");
|
||||
if (is_definition)
|
||||
// need to extend range here to include the token
|
||||
end = get_next_location(tu, file, end);
|
||||
}
|
||||
|
||||
if (!is_definition && !token_after_is(tu, file, cur, end, ";"))
|
||||
{
|
||||
// we do not have a body, but it is not a declaration either
|
||||
do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue