Add line numbers to diagnostics
This commit is contained in:
parent
7c30ba7c46
commit
d088b44db6
3 changed files with 14 additions and 5 deletions
|
|
@ -19,7 +19,13 @@ namespace cppast
|
|||
{
|
||||
inline source_location make_location(const CXCursor& cur)
|
||||
{
|
||||
return source_location::make_entity(get_display_name(cur).c_str());
|
||||
auto loc = clang_getCursorLocation(cur);
|
||||
|
||||
CXString file;
|
||||
unsigned line;
|
||||
clang_getPresumedLocation(loc, &file, &line, nullptr);
|
||||
|
||||
return source_location::make_file(cxstring(file).c_str(), line);
|
||||
}
|
||||
|
||||
inline source_location make_location(const CXType& type)
|
||||
|
|
|
|||
|
|
@ -701,7 +701,8 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
|
|||
{
|
||||
auto message = detail::format("parsing macro '", macro->name(), "'");
|
||||
logger.log("preprocessor",
|
||||
diagnostic{std::move(message), source_location::make_file(path),
|
||||
diagnostic{std::move(message),
|
||||
source_location::make_file(path, p.cur_line()),
|
||||
severity::debug});
|
||||
}
|
||||
|
||||
|
|
@ -715,7 +716,8 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
|
|||
{
|
||||
auto message = detail::format("undefining macro '", undef.value(), "'");
|
||||
logger.log("preprocessor",
|
||||
diagnostic{std::move(message), source_location::make_file(path),
|
||||
diagnostic{std::move(message),
|
||||
source_location::make_file(path, p.cur_line()),
|
||||
severity::debug});
|
||||
}
|
||||
result.macros.erase(std::remove_if(result.macros.begin(), result.macros.end(),
|
||||
|
|
@ -732,7 +734,8 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
|
|||
auto message =
|
||||
detail::format("parsing include '", include.value().file.name(), "'");
|
||||
logger.log("preprocessor",
|
||||
diagnostic{std::move(message), source_location::make_file(path),
|
||||
diagnostic{std::move(message),
|
||||
source_location::make_file(path, p.cur_line()),
|
||||
severity::debug});
|
||||
}
|
||||
result.includes.push_back(std::move(include.value()));
|
||||
|
|
|
|||
|
|
@ -553,7 +553,7 @@ namespace
|
|||
{
|
||||
auto msg = detail::format("unexpected type of kind '",
|
||||
detail::get_type_kind_spelling(type).c_str(), "'");
|
||||
auto location = source_location::make_entity(get_type_spelling(type).c_str());
|
||||
auto location = detail::make_location(type);
|
||||
context.logger->log("libclang parser", diagnostic{msg, location, severity::warning});
|
||||
}
|
||||
// fallthrough
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue