Skip to content

Conversation

@llvmbot
Copy link
Member

@llvmbot llvmbot commented Oct 18, 2024

Backport 67f576f

Requested by: @owenca

@llvmbot llvmbot added this to the LLVM 19.X Release milestone Oct 18, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Oct 18, 2024

@mydeveloperday What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Oct 18, 2024

@llvm/pr-subscribers-clang-format

Author: None (llvmbot)

Changes

Backport 67f576f

Requested by: @owenca


Full diff: https://github.com/llvm/llvm-project/pull/112815.diff

2 Files Affected:

  • (modified) clang/lib/Format/UnwrappedLineParser.cpp (+5)
  • (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+6)
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 631c7c62baac18..a5268e153bcc5b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2500,6 +2500,11 @@ bool UnwrappedLineParser::parseBracedList(bool IsAngleBracket, bool IsEnum) {
       // Assume there are no blocks inside a braced init list apart
       // from the ones we explicitly parse out (like lambdas).
       FormatTok->setBlockKind(BK_BracedInit);
+      if (!IsAngleBracket) {
+        auto *Prev = FormatTok->Previous;
+        if (Prev && Prev->is(tok::greater))
+          Prev->setFinalizedType(TT_TemplateCloser);
+      }
       nextToken();
       parseBracedList();
       break;
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 6f3ef3b646c619..4acd900ff061f8 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -3404,6 +3404,12 @@ TEST_F(TokenAnnotatorTest, TemplateInstantiation) {
   ASSERT_EQ(Tokens.size(), 21u) << Tokens;
   EXPECT_TOKEN(Tokens[4], tok::less, TT_TemplateOpener);
   EXPECT_TOKEN(Tokens[16], tok::greater, TT_TemplateCloser);
+
+  Tokens =
+      annotate("auto x{std::conditional_t<T::value == U::value, T, U>{}};");
+  ASSERT_EQ(Tokens.size(), 24u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[18], tok::greater, TT_TemplateCloser);
 }
 
 } // namespace

@owenca owenca added the regression:19 Regression in 19 release label Oct 18, 2024
@tru tru merged commit 4b322f6 into llvm:release/19.x Oct 29, 2024
8 of 10 checks passed
@github-actions
Copy link

@owenca (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang-format regression:19 Regression in 19 release

Projects

Development

Successfully merging this pull request may close these issues.

4 participants