Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,9 @@ class AnnotatingParser {
if (!Tok.Previous || Tok.isNot(tok::identifier) || Tok.is(TT_ClassHeadName))
return false;

if (Tok.endsSequence(Keywords.kw_final, TT_ClassHeadName))
return false;

if ((Style.isJavaScript() || Style.isJava()) && Tok.is(Keywords.kw_extends))
return false;

Expand Down
7 changes: 7 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,13 @@ TEST_F(TokenAnnotatorTest, UnderstandsStructs) {
EXPECT_TOKEN(Tokens[19], tok::l_brace, TT_StructLBrace);
EXPECT_TOKEN(Tokens[20], tok::r_brace, TT_StructRBrace);

Tokens = annotate("class Outer {\n"
" struct Inner final : Base {};\n"
"};");
ASSERT_EQ(Tokens.size(), 14u) << Tokens;
EXPECT_TOKEN(Tokens[5], tok::identifier, TT_Unknown); // Not TT_StartOfName
EXPECT_TOKEN(Tokens[6], tok::colon, TT_InheritanceColon);

constexpr StringRef Code("struct EXPORT StructName {};");

Tokens = annotate(Code);
Expand Down