Extend variable range to include attributes

Fixes #27.
This commit is contained in:
Jonathan Müller 2018-12-18 16:40:59 +01:00
commit 51c2fc6569
2 changed files with 7 additions and 1 deletions

View file

@ -308,6 +308,10 @@ Extent get_extent(const CXTranslationUnit& tu, const CXFile& file, const CXCurso
} }
else if (cursor_is_var(kind) || cursor_is_var(clang_getTemplateCursorKind(cur))) else if (cursor_is_var(kind) || cursor_is_var(clang_getTemplateCursorKind(cur)))
{ {
// need to extend until the semicolon
while (!token_at_is(tu, file, end, ";"))
end = get_next_location(tu, file, end, 1);
if (has_inline_type_definition(cur)) if (has_inline_type_definition(cur))
{ {
// the type is declared inline, // the type is declared inline,

View file

@ -248,6 +248,8 @@ struct [[inline_type]] inline_type
[[field]] int field; [[field]] int field;
} }
[[s]] s; [[s]] s;
int t [[t]];
)"; )";
auto file = parse({}, "cpp_attribute__matching.cpp", code); auto file = parse({}, "cpp_attribute__matching.cpp", code);
@ -275,5 +277,5 @@ struct [[inline_type]] inline_type
return true; return true;
}); });
REQUIRE(count == 43u); REQUIRE(count == 44u);
} }