[llvm-branch-commits] [clang] 95fa0be - [clang-format] Correctly identify token-pasted record names (#106484)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 3 00:01:32 PDT 2024
Author: Owen Pan
Date: 2024-09-01T10:43:34Z
New Revision: 95fa0bee9314a878b3a58d748998c3b3ef42bd75
URL: https://github.com/llvm/llvm-project/commit/95fa0bee9314a878b3a58d748998c3b3ef42bd75
DIFF: https://github.com/llvm/llvm-project/commit/95fa0bee9314a878b3a58d748998c3b3ef42bd75.diff
LOG: [clang-format] Correctly identify token-pasted record names (#106484)
See
https://github.com/llvm/llvm-project/pull/89706#issuecomment-2315549955.
(cherry picked from commit 7579787e05966f21684dd4b4a15b9deac13d09e1)
Added:
Modified:
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 53ddb710d2143b..7f5d157ae95891 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -4016,6 +4016,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
}
break;
case tok::coloncolon:
+ case tok::hashhash:
break;
default:
if (!JSPastExtendsOrImplements && !ClassName &&
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 81e2628f28e583..f0533c92f6538c 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3208,6 +3208,16 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
ASSERT_EQ(Tokens.size(), 11u) << Tokens;
EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_ClassLBrace);
EXPECT_BRACE_KIND(Tokens[7], BK_Block);
+ EXPECT_TOKEN(Tokens[8], tok::r_brace, TT_ClassRBrace);
+ EXPECT_BRACE_KIND(Tokens[8], BK_Block);
+
+ Tokens = annotate("#define FOO(X) \\\n"
+ " struct X##_tag_ {};");
+ ASSERT_EQ(Tokens.size(), 14u) << Tokens;
+ EXPECT_TOKEN(Tokens[10], tok::l_brace, TT_StructLBrace);
+ EXPECT_BRACE_KIND(Tokens[10], BK_Block);
+ EXPECT_TOKEN(Tokens[11], tok::r_brace, TT_StructRBrace);
+ EXPECT_BRACE_KIND(Tokens[11], BK_Block);
}
TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {
More information about the llvm-branch-commits
mailing list