diff --git a/src/libclang/cxtokenizer.cpp b/src/libclang/cxtokenizer.cpp index aefd5c9..4fd7db7 100644 --- a/src/libclang/cxtokenizer.cpp +++ b/src/libclang/cxtokenizer.cpp @@ -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))) { + // 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)) { // the type is declared inline, diff --git a/test/cpp_attribute.cpp b/test/cpp_attribute.cpp index c427a38..17da2fe 100644 --- a/test/cpp_attribute.cpp +++ b/test/cpp_attribute.cpp @@ -248,6 +248,8 @@ struct [[inline_type]] inline_type [[field]] int field; } [[s]] s; + +int t [[t]]; )"; auto file = parse({}, "cpp_attribute__matching.cpp", code); @@ -275,5 +277,5 @@ struct [[inline_type]] inline_type return true; }); - REQUIRE(count == 43u); + REQUIRE(count == 44u); }