[clang] [clang-format] Allow decltype in requires clause (PR #78847)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 20 12:12:41 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);
}
----------------
HazardyKnusperkeks wrote:
For the mentioned test coverage (you are completely right), something like:
```c++
int foo(auto t) {
if (requires (decltype(t) x) {x.foo();}) {
return 1;
}
return 0;
}
```
https://github.com/llvm/llvm-project/pull/78847
More information about the cfe-commits
mailing list