[clang] [clang-format] Allow decltype in requires clause (PR #78847)
Emilia Kond via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 21 00:11:55 PST 2024
================
@@ -1071,6 +1071,16 @@ TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) {
"concept C = (!Foo<T>) && Bar;");
ASSERT_EQ(Tokens.size(), 19u) << Tokens;
EXPECT_TOKEN(Tokens[15], tok::ampamp, TT_BinaryOperator);
+
+ Tokens = annotate("void f() & requires(C<decltype(x)>) {}");
+ ASSERT_EQ(Tokens.size(), 18u) << Tokens;
+ EXPECT_TOKEN(Tokens[4], tok::amp, TT_PointerOrReference);
+ EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause);
+
+ Tokens = annotate("auto f() -> int& requires(C<decltype(x)>) {}");
+ ASSERT_EQ(Tokens.size(), 20u) << Tokens;
+ EXPECT_TOKEN(Tokens[6], tok::amp, TT_PointerOrReference);
+ EXPECT_TOKEN(Tokens[7], tok::kw_requires, TT_RequiresClause);
}
----------------
rymiel wrote:
Well, the simplest fix is to remove `case tok::r_paren:` on line 3424 which always led to parseRequiresClause. Surprisingly removing that breaks no tests, but surely @HazardyKnusperkeks you put it there for a reason? I'm not sure if such a fix is the best idea
https://github.com/llvm/llvm-project/pull/78847
More information about the cfe-commits
mailing list