|
|
|
|
@ -2,8 +2,24 @@
|
|
|
|
|
#include "Utility.h" |
|
|
|
|
#include <algorithm> |
|
|
|
|
|
|
|
|
|
clang::CursorKind clang::Cursor::get_kind() { |
|
|
|
|
return static_cast<CursorKind>(clang_getCursorKind(this->cx_cursor)); |
|
|
|
|
std::string clang::Cursor::Type::get_spelling() const { |
|
|
|
|
return to_string(clang_getTypeSpelling(cx_type)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::Cursor::Type clang::Cursor::Type::get_result() const { |
|
|
|
|
return Type(clang_getResultType(cx_type)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool clang::Cursor::Type::operator==(const Cursor::Type& rhs) const { |
|
|
|
|
return clang_equalTypes(cx_type, rhs.cx_type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::Cursor::Kind clang::Cursor::get_kind() const { |
|
|
|
|
return static_cast<Kind>(clang_getCursorKind(cx_cursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::Cursor::Type clang::Cursor::get_type() const { |
|
|
|
|
return Type(clang_getCursorType(cx_cursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::SourceLocation clang::Cursor::get_source_location() const { |
|
|
|
|
@ -15,19 +31,35 @@ clang::SourceRange clang::Cursor::get_source_range() const {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string clang::Cursor::get_spelling() const { |
|
|
|
|
return clang::to_string(clang_getCursorSpelling(cx_cursor)); |
|
|
|
|
return to_string(clang_getCursorSpelling(cx_cursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string clang::Cursor::get_usr() const { |
|
|
|
|
return clang::to_string(clang_getCursorUSR(cx_cursor)); |
|
|
|
|
return to_string(clang_getCursorUSR(cx_cursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::Cursor clang::Cursor::get_referenced() const { |
|
|
|
|
return Cursor(clang_getCursorReferenced(cx_cursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::Cursor clang::Cursor::get_canonical() const { |
|
|
|
|
return Cursor(clang_getCanonicalCursor(cx_cursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::Cursor clang::Cursor::get_definition() const { |
|
|
|
|
return Cursor(clang_getCursorDefinition(cx_cursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::Cursor clang::Cursor::get_semantic_parent() const { |
|
|
|
|
return clang::Cursor(clang_getCursorSemanticParent(cx_cursor)); |
|
|
|
|
return Cursor(clang_getCursorSemanticParent(cx_cursor)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::vector<clang::Cursor> clang::Cursor::get_arguments() const { |
|
|
|
|
std::vector<Cursor> cursors; |
|
|
|
|
auto size=clang_Cursor_getNumArguments(cx_cursor); |
|
|
|
|
for(int c=0;c<size;++c) |
|
|
|
|
cursors.emplace_back(clang_Cursor_getArgument(cx_cursor, c)); |
|
|
|
|
return cursors; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
clang::Cursor::operator bool() const { |
|
|
|
|
@ -38,7 +70,7 @@ bool clang::Cursor::operator==(const Cursor& rhs) const {
|
|
|
|
|
return clang_equalCursors(cx_cursor, rhs.cx_cursor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool clang::Cursor::has_type() { |
|
|
|
|
bool clang::Cursor::has_type_description() { |
|
|
|
|
auto referenced=clang_getCursorReferenced(cx_cursor); |
|
|
|
|
if(clang_Cursor_isNull(referenced)) |
|
|
|
|
return false; |
|
|
|
|
@ -46,18 +78,18 @@ bool clang::Cursor::has_type() {
|
|
|
|
|
return type.kind!=0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::string clang::Cursor::get_type() { |
|
|
|
|
std::string clang::Cursor::get_type_description() { |
|
|
|
|
std::string spelling; |
|
|
|
|
auto referenced=clang_getCursorReferenced(cx_cursor); |
|
|
|
|
if(!clang_Cursor_isNull(referenced)) { |
|
|
|
|
auto type=clang_getCursorType(referenced); |
|
|
|
|
spelling=clang::to_string(clang_getTypeSpelling(type)); |
|
|
|
|
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=clang::to_string(clang_getTypeSpelling(canonical_type)); |
|
|
|
|
auto canonical_spelling=to_string(clang_getTypeSpelling(canonical_type)); |
|
|
|
|
if(spelling.size()>5 && spelling[4]==' ' && spelling[5]=='&' && spelling!=canonical_spelling) |
|
|
|
|
return canonical_spelling+" &"; |
|
|
|
|
else |
|
|
|
|
@ -67,7 +99,7 @@ std::string clang::Cursor::get_type() {
|
|
|
|
|
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=clang::to_string(clang_getTypeSpelling(canonical_type)); |
|
|
|
|
auto canonical_spelling=to_string(clang_getTypeSpelling(canonical_type)); |
|
|
|
|
if(spelling.size()>11 && spelling[10]==' ' && spelling[11]=='&' && spelling!=canonical_spelling) |
|
|
|
|
return canonical_spelling+" &"; |
|
|
|
|
else |
|
|
|
|
@ -83,7 +115,7 @@ std::string clang::Cursor::get_brief_comments() {
|
|
|
|
|
std::string comment_string; |
|
|
|
|
auto referenced=get_referenced(); |
|
|
|
|
if(referenced) { |
|
|
|
|
comment_string=clang::to_string(clang_Cursor_getBriefCommentText(referenced.cx_cursor)); |
|
|
|
|
comment_string=to_string(clang_Cursor_getBriefCommentText(referenced.cx_cursor)); |
|
|
|
|
} |
|
|
|
|
return comment_string; |
|
|
|
|
} |
|
|
|
|
|