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,8 +87,10 @@ 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)
{ {

View file

@ -177,21 +177,27 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
break; break;
} }
auto msg = detail::format("unhandled cursor of kind '", if (!clang_isAttribute(clang_getCursorKind(cur)))
detail::get_cursor_kind_spelling(cur).c_str(), "'"); {
context.logger->log("libclang parser", auto msg = detail::format("unhandled cursor of kind '",
diagnostic{std::move(msg), detail::make_location(cur), severity::warning}); 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 // build unexposed entity
auto name = detail::get_cursor_name(cur); auto name = detail::get_cursor_name(cur);
detail::tokenizer tokenizer(context.tu, context.file, cur); detail::tokenizer tokenizer(context.tu, context.file, cur);
detail::token_stream stream(tokenizer, cur); detail::token_stream stream(tokenizer, cur);
auto spelling = detail::to_string(stream, stream.end()); auto spelling = detail::to_string(stream, stream.end());
if (name.empty()) if (name.empty())
return cpp_unexposed_entity::build(std::move(spelling)); 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 else
return cpp_unexposed_entity::build(*context.idx, detail::get_entity_id(cur), name.c_str(), return nullptr;
std::move(spelling));
} }
catch (parse_error& ex) catch (parse_error& ex)
{ {