From a89ebcdf0a9cb4040fd39b7a4892cc1a0cb4ecbb Mon Sep 17 00:00:00 2001 From: Omer Ozarslan Date: Fri, 16 Aug 2019 05:58:48 -0500 Subject: [PATCH] Use empty underlying type for aliases of anonymous types (#83) Fixes #58 --- src/libclang/type_parser.cpp | 2 +- test/cpp_type_alias.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libclang/type_parser.cpp b/src/libclang/type_parser.cpp index 1013c94..bfdf27b 100644 --- a/src/libclang/type_parser.cpp +++ b/src/libclang/type_parser.cpp @@ -637,7 +637,7 @@ std::unique_ptr parse_type_impl(const detail::parse_context& context, case CXType_Typedef: return make_leave_type(cur, type, [&](std::string&& spelling) { auto decl = clang_getTypeDeclaration(type); - if (remove_prefix(spelling, "(anonymous", false)) + if (detail::cxstring(clang_getCursorSpelling(decl)).empty()) spelling = ""; // anonymous type return cpp_user_defined_type::build( cpp_type_ref(detail::get_entity_id(decl), std::move(spelling))); diff --git a/test/cpp_type_alias.cpp b/test/cpp_type_alias.cpp index e20b614..53827b0 100644 --- a/test/cpp_type_alias.cpp +++ b/test/cpp_type_alias.cpp @@ -509,7 +509,7 @@ typedef decltype(0) w; } else if (alias.name() == "v") { - auto type = cpp_user_defined_type::build(cpp_type_ref(cpp_entity_id(""), "v")); + auto type = cpp_user_defined_type::build(cpp_type_ref(cpp_entity_id(""), "")); REQUIRE(equal_types(idx, alias.underlying_type(), *type)); return false; }