Skip to content

Commit e5fa6b7

Browse files
committed
Fix entity id for elaborated type referencing using declaration
Fixes #149.
1 parent a3393ed commit e5fa6b7

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/libclang/type_parser.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,21 @@ std::unique_ptr<cpp_type> parse_type_impl(const detail::parse_context& context,
673673
case CXType_Typedef:
674674
return make_leave_type(cur, type, [&](std::string&& spelling) {
675675
auto decl = clang_getTypeDeclaration(type);
676-
if (detail::cxstring(clang_getCursorSpelling(decl)).empty())
677-
spelling = ""; // anonymous type
678-
return cpp_user_defined_type::build(
679-
cpp_type_ref(detail::get_entity_id(decl), std::move(spelling)));
676+
if (clang_isInvalid(clang_getCursorKind(decl)))
677+
{
678+
// We can reach this point if we have an elaborated type referencing a using
679+
// declaration. Give it an invalid id, since we have no way of retrieving it, but
680+
// keep the spelling.
681+
return cpp_user_defined_type::build(
682+
cpp_type_ref(cpp_entity_id(""), std::move(spelling)));
683+
}
684+
else
685+
{
686+
if (detail::cxstring(clang_getCursorSpelling(decl)).empty())
687+
spelling = ""; // anonymous type
688+
return cpp_user_defined_type::build(
689+
cpp_type_ref(detail::get_entity_id(decl), std::move(spelling)));
690+
}
680691
});
681692

682693
case CXType_Pointer: {

0 commit comments

Comments
 (0)