Parse typedefs

This commit is contained in:
Jonathan Müller 2017-02-23 15:45:27 +01:00
commit 0794ff1420
10 changed files with 200 additions and 10 deletions

View file

@ -35,6 +35,7 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
return parse_cpp_using_declaration(context, cur);
case CXCursor_TypeAliasDecl:
case CXCursor_TypedefDecl:
return parse_cpp_type_alias(context, cur);
default:

View file

@ -414,16 +414,10 @@ catch (parse_error& ex)
std::unique_ptr<cpp_entity> detail::parse_cpp_type_alias(const detail::parse_context& context,
const CXCursor& cur)
{
DEBUG_ASSERT(cur.kind == CXCursor_TypeAliasDecl, detail::assert_handler{});
detail::tokenizer tokenizer(context.tu, context.file, cur);
detail::token_stream stream(tokenizer, cur);
// using <identifier> = ...
detail::skip(stream, "using");
auto& name = stream.get().value();
detail::skip(stream, "=");
DEBUG_ASSERT(cur.kind == CXCursor_TypeAliasDecl || cur.kind == CXCursor_TypedefDecl,
detail::assert_handler{});
auto name = cxstring(clang_getCursorSpelling(cur));
auto type = parse_type(context, clang_getTypedefDeclUnderlyingType(cur));
if (!type)
return nullptr;