[clang] [clang-format] Handle template closer followed by braces (PR #110971)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 3 21:07:19 PDT 2024


================
@@ -3538,6 +3538,11 @@ TEST_F(TokenAnnotatorTest, TemplateInstantiation) {
   ASSERT_EQ(Tokens.size(), 11u) << Tokens;
   EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
   EXPECT_TOKEN(Tokens[6], tok::greater, TT_TemplateCloser);
+
+  Tokens = annotate("return std::conditional_t<T::value == U::value, T, U>{};");
+  ASSERT_EQ(Tokens.size(), 21u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[16], tok::greater, TT_TemplateCloser);
----------------
owenca wrote:

The root cause was the misannotation of the `>`, so we add an annotation test instead of verifying the spacing directly.

https://github.com/llvm/llvm-project/pull/110971


More information about the cfe-commits mailing list