diff options
author | Owen Pan <owenpiano@gmail.com> | 2025-06-14 00:21:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-14 00:21:39 -0700 |
commit | 2e7fbb94bc268d37996408a525781961989d8627 (patch) | |
tree | 63c8ac9a7413178ad28d530f8fdabcff14833eb5 /clang/unittests/Format | |
parent | 2796c412499a276ad23ae184daac33175c32424f (diff) | |
download | llvm-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.cpp | 7 |
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) { |