diff --git a/src/cursor.cc b/src/cursor.cc index 2ed307e..f1dea65 100644 --- a/src/cursor.cc +++ b/src/cursor.cc @@ -217,39 +217,18 @@ bool clangmm::Cursor::is_valid_kind() const { } std::string clangmm::Cursor::get_type_description() const { - std::string spelling; + auto type = clang_getCursorType(cx_cursor); + if(type.kind != CXTypeKind::CXType_Invalid) + return to_string(clang_getTypeSpelling(type)); + auto referenced = clang_getCursorReferenced(cx_cursor); if(!clang_Cursor_isNull(referenced)) { auto type = clang_getCursorType(referenced); - spelling = to_string(clang_getTypeSpelling(type)); - -#if CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR < 32 - const std::string auto_str = "auto"; - if(spelling.size() >= 4 && std::equal(auto_str.begin(), auto_str.end(), spelling.begin())) { - auto canonical_type = clang_getCanonicalType(clang_getCursorType(cx_cursor)); - auto canonical_spelling = to_string(clang_getTypeSpelling(canonical_type)); - if(spelling.size() > 5 && spelling[4] == ' ' && spelling[5] == '&' && spelling != canonical_spelling) - return canonical_spelling + " &"; - else - return canonical_spelling; - } - - const std::string const_auto_str = "const auto"; - if(spelling.size() >= 10 && std::equal(const_auto_str.begin(), const_auto_str.end(), spelling.begin())) { - auto canonical_type = clang_getCanonicalType(clang_getCursorType(cx_cursor)); - auto canonical_spelling = to_string(clang_getTypeSpelling(canonical_type)); - if(spelling.size() > 11 && spelling[10] == ' ' && spelling[11] == '&' && spelling != canonical_spelling) - return canonical_spelling + " &"; - else - return canonical_spelling; - } -#endif + if(type.kind != CXTypeKind::CXType_Invalid) + return to_string(clang_getTypeSpelling(type)); } - if(spelling.empty()) - return get_spelling(); - - return spelling; + return get_spelling(); } std::string clangmm::Cursor::get_brief_comments() const {