llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) <details> <summary>Changes</summary> Fix #<!-- -->136092 --- Full diff: https://github.com/llvm/llvm-project/pull/136109.diff 2 Files Affected: - (modified) clang/lib/Format/FormatToken.h (+3-2) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+6) ``````````diff diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 87e16397ad069..946cd7b81587f 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -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 diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 2c7319ccefec2..0f144d043667e 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -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 `````````` </details> https://github.com/llvm/llvm-project/pull/136109 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits