Add diagnostic on ignored cursor type

This commit is contained in:
Jonathan Müller 2017-02-22 20:49:20 +01:00
commit a38641ecb1
4 changed files with 17 additions and 1 deletions

View file

@ -16,6 +16,11 @@ detail::cxstring detail::get_display_name(const CXCursor& cur) noexcept
return cxstring(clang_getCursorDisplayName(cur));
}
detail::cxstring detail::get_cursor_kind_spelling(const CXCursor& cur) noexcept
{
return cxstring(clang_getCursorKindSpelling(clang_getCursorKind(cur)));
}
namespace
{
std::mutex mtx;

View file

@ -13,6 +13,8 @@ namespace cppast
{
cxstring get_display_name(const CXCursor& cur) noexcept;
cxstring get_cursor_kind_spelling(const CXCursor& cur) noexcept;
void print_cursor_info(const CXCursor& cur) noexcept;
void print_tokens(const cxtranslation_unit& tu, const CXFile& file,

View file

@ -17,6 +17,11 @@ namespace cppast
{
namespace detail
{
inline source_location make_location(const CXCursor& cur)
{
return source_location::make(get_display_name(cur).c_str());
}
// thrown on a parsing error
// not meant to escape to the user
class parse_error : public std::logic_error
@ -28,7 +33,7 @@ namespace cppast
}
parse_error(const CXCursor& cur, std::string message)
: parse_error(source_location::make(get_display_name(cur).c_str()), std::move(message))
: parse_error(make_location(cur), std::move(message))
{
}

View file

@ -38,6 +38,10 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
break;
}
auto msg = format("unhandled cursor of kind '", get_cursor_kind_spelling(cur).c_str(), "'");
context.logger->log("libclang parser",
diagnostic{std::move(msg), make_location(cur), severity::warning});
return nullptr;
}
catch (parse_error& ex)