Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions clang/lib/Format/FormatToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,9 @@ struct FormatToken {
[[nodiscard]] bool isTypeOrIdentifier(const LangOptions &LangOpts) const;

bool isObjCAccessSpecifier() const {
return Next && Next->isOneOf(tok::objc_public, tok::objc_protected,
tok::objc_package, tok::objc_private);
return is(tok::at) && Next &&
Next->isOneOf(tok::objc_public, tok::objc_protected,
tok::objc_package, tok::objc_private);
}

/// Returns whether \p Tok is ([{ or an opening < of a template or in
Expand Down
6 changes: 6 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3963,6 +3963,12 @@ TEST_F(TokenAnnotatorTest, UTF8StringLiteral) {
EXPECT_TOKEN(Tokens[1], tok::utf8_string_literal, TT_Unknown);
}

TEST_F(TokenAnnotatorTest, IdentifierPackage) {
auto Tokens = annotate("auto package;");
ASSERT_EQ(Tokens.size(), 4u) << Tokens;
EXPECT_TOKEN(Tokens[1], tok::identifier, TT_StartOfName);
}

} // namespace
} // namespace format
} // namespace clang
Loading