Skip attribute cursors
This commit is contained in:
parent
b0cd795836
commit
13d9ac6147
2 changed files with 25 additions and 14 deletions
|
|
@ -14,6 +14,9 @@ namespace
|
|||
std::unique_ptr<cpp_enum_value> parse_enum_value(const detail::parse_context& context,
|
||||
const CXCursor& cur)
|
||||
{
|
||||
if (clang_isAttribute(clang_getCursorKind(cur)))
|
||||
return nullptr;
|
||||
|
||||
DEBUG_ASSERT(cur.kind == CXCursor_EnumConstantDecl, detail::parse_error_handler{}, cur,
|
||||
"unexpected child cursor of enum");
|
||||
|
||||
|
|
@ -84,8 +87,10 @@ std::unique_ptr<cpp_entity> detail::parse_cpp_enum(const detail::parse_context&
|
|||
{
|
||||
auto entity = parse_enum_value(context, child);
|
||||
if (entity)
|
||||
{
|
||||
context.comments.match(*entity, child);
|
||||
builder.add_value(std::move(entity));
|
||||
builder.add_value(std::move(entity));
|
||||
}
|
||||
}
|
||||
catch (parse_error& ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -177,21 +177,27 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
|
|||
break;
|
||||
}
|
||||
|
||||
auto msg = detail::format("unhandled cursor of kind '",
|
||||
detail::get_cursor_kind_spelling(cur).c_str(), "'");
|
||||
context.logger->log("libclang parser",
|
||||
diagnostic{std::move(msg), detail::make_location(cur), severity::warning});
|
||||
if (!clang_isAttribute(clang_getCursorKind(cur)))
|
||||
{
|
||||
auto msg = detail::format("unhandled cursor of kind '",
|
||||
detail::get_cursor_kind_spelling(cur).c_str(), "'");
|
||||
context.logger->log("libclang parser",
|
||||
diagnostic{std::move(msg), detail::make_location(cur),
|
||||
severity::warning});
|
||||
|
||||
// build unexposed entity
|
||||
auto name = detail::get_cursor_name(cur);
|
||||
detail::tokenizer tokenizer(context.tu, context.file, cur);
|
||||
detail::token_stream stream(tokenizer, cur);
|
||||
auto spelling = detail::to_string(stream, stream.end());
|
||||
if (name.empty())
|
||||
return cpp_unexposed_entity::build(std::move(spelling));
|
||||
// build unexposed entity
|
||||
auto name = detail::get_cursor_name(cur);
|
||||
detail::tokenizer tokenizer(context.tu, context.file, cur);
|
||||
detail::token_stream stream(tokenizer, cur);
|
||||
auto spelling = detail::to_string(stream, stream.end());
|
||||
if (name.empty())
|
||||
return cpp_unexposed_entity::build(std::move(spelling));
|
||||
else
|
||||
return cpp_unexposed_entity::build(*context.idx, detail::get_entity_id(cur),
|
||||
name.c_str(), std::move(spelling));
|
||||
}
|
||||
else
|
||||
return cpp_unexposed_entity::build(*context.idx, detail::get_entity_id(cur), name.c_str(),
|
||||
std::move(spelling));
|
||||
return nullptr;
|
||||
}
|
||||
catch (parse_error& ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue