[clang] c5cce48 - Revert "[clang-format] Handle token-pasted function decl names (#142251)"
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 1 23:36:50 PDT 2025
Author: Owen Pan
Date: 2025-06-01T23:32:00-07:00
New Revision: c5cce4861cb011d10af7f6afba4176682f5f862f
URL: https://github.com/llvm/llvm-project/commit/c5cce4861cb011d10af7f6afba4176682f5f862f
DIFF: https://github.com/llvm/llvm-project/commit/c5cce4861cb011d10af7f6afba4176682f5f862f.diff
LOG: Revert "[clang-format] Handle token-pasted function decl names (#142251)"
This reverts commit 29f79ea3c59649f7686a09845665660c25ca3f9b which caused a regression.
See https://github.com/llvm/llvm-project/pull/142251#issuecomment-2928718530.
Added:
Modified:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 52100d195fe7a..da1b6dd5254b8 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3976,13 +3976,8 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
Tok; Tok = Tok->Next) {
if (Tok->is(TT_StartOfName))
SeenName = true;
- const auto *Previous = Tok->Previous;
- if (Previous->EndsCppAttributeGroup) {
+ if (Tok->Previous->EndsCppAttributeGroup)
AfterLastAttribute = Tok;
- } else if (Line.InMacroBody &&
- Previous->endsSequence(tok::hashhash, TT_StartOfName)) {
- Tok->setType(TT_StartOfName);
- }
if (const bool IsCtorOrDtor = Tok->is(TT_CtorDtorDeclName);
IsCtorOrDtor ||
isFunctionDeclarationName(LangOpts, *Tok, Line, ClosingParen)) {
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index ba6a9f813f052..1a5ed4b9040c2 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2257,13 +2257,6 @@ TEST_F(TokenAnnotatorTest, UnderstandsFunctionDeclarationNames) {
EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);
EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_FunctionDeclarationLParen);
- Tokens = annotate("#define FUNC(foo, bar) \\\n"
- " auto foo##bar() -> Type {}");
- ASSERT_EQ(Tokens.size(), 19u) << Tokens;
- EXPECT_TOKEN(Tokens[11], tok::identifier, TT_FunctionDeclarationName);
- EXPECT_TOKEN(Tokens[12], tok::l_paren, TT_FunctionDeclarationLParen);
- EXPECT_TOKEN(Tokens[14], tok::arrow, TT_TrailingReturnArrow);
-
Tokens = annotate("int iso_time(time_t);");
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);
More information about the cfe-commits
mailing list