aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2025-06-02 13:35:27 -0700
committerGitHub <noreply@github.com>2025-06-02 13:35:27 -0700
commit7bf5862dbfda590282f50b14e6d7d5f990bf1900 (patch)
tree154ec2e24ac40dd7844781d314a39a5ee1db1971 /clang/unittests/Format
parent5628bf5a1e99375065df2b9652069adc9afcd655 (diff)
downloadllvm-7bf5862dbfda590282f50b14e6d7d5f990bf1900.zip
llvm-7bf5862dbfda590282f50b14e6d7d5f990bf1900.tar.gz
llvm-7bf5862dbfda590282f50b14e6d7d5f990bf1900.tar.bz2
[clang-format] Correctly annotate token-pasted function decl names (#142337)
Fix #142178
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/TokenAnnotatorTest.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 1a5ed4b..8731dc3 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2257,6 +2257,13 @@ 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, baz) \\\n"
+ " auto foo##bar##baz() -> Type {}");
+ ASSERT_EQ(Tokens.size(), 23u) << Tokens;
+ EXPECT_TOKEN(Tokens[11], tok::identifier, TT_FunctionDeclarationName);
+ EXPECT_TOKEN(Tokens[16], tok::l_paren, TT_FunctionDeclarationLParen);
+ EXPECT_TOKEN(Tokens[18], 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);