Skip attribute cursors

This commit is contained in:
Jonathan Müller 2017-06-06 17:36:27 +02:00
commit 13d9ac6147
2 changed files with 25 additions and 14 deletions

View file

@ -14,6 +14,9 @@ namespace
std::unique_ptr<cpp_enum_value> parse_enum_value(const detail::parse_context& context, std::unique_ptr<cpp_enum_value> parse_enum_value(const detail::parse_context& context,
const CXCursor& cur) const CXCursor& cur)
{ {
if (clang_isAttribute(clang_getCursorKind(cur)))
return nullptr;
DEBUG_ASSERT(cur.kind == CXCursor_EnumConstantDecl, detail::parse_error_handler{}, cur, DEBUG_ASSERT(cur.kind == CXCursor_EnumConstantDecl, detail::parse_error_handler{}, cur,
"unexpected child cursor of enum"); "unexpected child cursor of enum");
@ -84,9 +87,11 @@ std::unique_ptr<cpp_entity> detail::parse_cpp_enum(const detail::parse_context&
{ {
auto entity = parse_enum_value(context, child); auto entity = parse_enum_value(context, child);
if (entity) if (entity)
{
context.comments.match(*entity, child); context.comments.match(*entity, child);
builder.add_value(std::move(entity)); builder.add_value(std::move(entity));
} }
}
catch (parse_error& ex) catch (parse_error& ex)
{ {
context.logger->log("libclang parser", ex.get_diagnostic()); context.logger->log("libclang parser", ex.get_diagnostic());

View file

@ -177,10 +177,13 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
break; break;
} }
if (!clang_isAttribute(clang_getCursorKind(cur)))
{
auto msg = detail::format("unhandled cursor of kind '", auto msg = detail::format("unhandled cursor of kind '",
detail::get_cursor_kind_spelling(cur).c_str(), "'"); detail::get_cursor_kind_spelling(cur).c_str(), "'");
context.logger->log("libclang parser", context.logger->log("libclang parser",
diagnostic{std::move(msg), detail::make_location(cur), severity::warning}); diagnostic{std::move(msg), detail::make_location(cur),
severity::warning});
// build unexposed entity // build unexposed entity
auto name = detail::get_cursor_name(cur); auto name = detail::get_cursor_name(cur);
@ -190,8 +193,11 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
if (name.empty()) if (name.empty())
return cpp_unexposed_entity::build(std::move(spelling)); return cpp_unexposed_entity::build(std::move(spelling));
else else
return cpp_unexposed_entity::build(*context.idx, detail::get_entity_id(cur), name.c_str(), return cpp_unexposed_entity::build(*context.idx, detail::get_entity_id(cur),
std::move(spelling)); name.c_str(), std::move(spelling));
}
else
return nullptr;
} }
catch (parse_error& ex) catch (parse_error& ex)
{ {