aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2025-06-14 00:21:39 -0700
committerGitHub <noreply@github.com>2025-06-14 00:21:39 -0700
commit2e7fbb94bc268d37996408a525781961989d8627 (patch)
tree63c8ac9a7413178ad28d530f8fdabcff14833eb5 /clang/unittests/Format
parent2796c412499a276ad23ae184daac33175c32424f (diff)
downloadllvm-2e7fbb94bc268d37996408a525781961989d8627.zip
llvm-2e7fbb94bc268d37996408a525781961989d8627.tar.gz
llvm-2e7fbb94bc268d37996408a525781961989d8627.tar.bz2
[clang-format] Fix a bug in annotating braces (#144095)
Stop looking for function decls after hitting a BK_BracedInit brace. Fixes #144057.
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 873c6c4..a1285e4 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3754,6 +3754,13 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
ASSERT_EQ(Tokens.size(), 9u) << Tokens;
EXPECT_BRACE_KIND(Tokens[4], BK_BracedInit);
EXPECT_BRACE_KIND(Tokens[6], BK_BracedInit);
+
+ Tokens = annotate("auto f1{&T::operator()};");
+ ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+ EXPECT_BRACE_KIND(Tokens[2], BK_BracedInit);
+ // Not TT_FunctionDeclarationName.
+ EXPECT_TOKEN(Tokens[6], tok::kw_operator, TT_Unknown);
+ EXPECT_BRACE_KIND(Tokens[9], BK_BracedInit);
}
TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) {