Skip to content

Commit c5cce48

Browse files
committed
Revert "[clang-format] Handle token-pasted function decl names (#142251)"
This reverts commit 29f79ea which caused a regression. See #142251 (comment).
1 parent faea938 commit c5cce48

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,13 +3976,8 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
39763976
Tok; Tok = Tok->Next) {
39773977
if (Tok->is(TT_StartOfName))
39783978
SeenName = true;
3979-
const auto *Previous = Tok->Previous;
3980-
if (Previous->EndsCppAttributeGroup) {
3979+
if (Tok->Previous->EndsCppAttributeGroup)
39813980
AfterLastAttribute = Tok;
3982-
} else if (Line.InMacroBody &&
3983-
Previous->endsSequence(tok::hashhash, TT_StartOfName)) {
3984-
Tok->setType(TT_StartOfName);
3985-
}
39863981
if (const bool IsCtorOrDtor = Tok->is(TT_CtorDtorDeclName);
39873982
IsCtorOrDtor ||
39883983
isFunctionDeclarationName(LangOpts, *Tok, Line, ClosingParen)) {

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,13 +2257,6 @@ TEST_F(TokenAnnotatorTest, UnderstandsFunctionDeclarationNames) {
22572257
EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);
22582258
EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_FunctionDeclarationLParen);
22592259

2260-
Tokens = annotate("#define FUNC(foo, bar) \\\n"
2261-
" auto foo##bar() -> Type {}");
2262-
ASSERT_EQ(Tokens.size(), 19u) << Tokens;
2263-
EXPECT_TOKEN(Tokens[11], tok::identifier, TT_FunctionDeclarationName);
2264-
EXPECT_TOKEN(Tokens[12], tok::l_paren, TT_FunctionDeclarationLParen);
2265-
EXPECT_TOKEN(Tokens[14], tok::arrow, TT_TrailingReturnArrow);
2266-
22672260
Tokens = annotate("int iso_time(time_t);");
22682261
ASSERT_EQ(Tokens.size(), 7u) << Tokens;
22692262
EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);

0 commit comments

Comments
 (0)