Commit 45abfa43 authored by Ole Christian Eidheim's avatar Ole Christian Eidheim
Browse files

Improved Cursor::get_type_description

parent b8ff60c0
Pipeline #133731619 passed with stage
in 3 minutes and 44 seconds
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment