We can now configure the space between requires and the following paren,separate for clauses and expressions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3999 | You meant "if there is one", right? | |
clang/unittests/Format/FormatTest.cpp | ||
15000 | I'd like to see some tests for mixed true/false, false/true values of these parameters. You only test false/false and true/true combinations so far. | |
23894 | This test seems redundant. Does it test something else than the above added ones? |
clang/lib/Format/TokenAnnotator.cpp | ||
---|---|---|
3255–3258 | Nit: remove else. |
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3999 | IMO these options should be named InRequiresClause and InRequiresExpression: that's where the space is going. The space doesn't go after the requires-clause. The space doesn't go after the requires-expression. | |
clang/include/clang/Format/Format.h | ||
3590 | Here and line 3380, and possibly elsewhere: s/parentheses/parenthesis/ | |
clang/unittests/Format/FormatTest.cpp | ||
15063 | Throughout, I'd like to see simpler test cases and more of them. E.g. I think this would suffice, in lieu of lines 14305–14369: SpaceAfterRequires.SpaceBeforeParensOptions.InRequiresClause = true; SpaceAfterRequires.SpaceBeforeParensOptions.InRequiresExpression = true; verifyFormat("void f(auto x) requires (requires (int i) { x+i; }) { }", SpaceAfterRequires); verifyFormat("if (requires (int i) { x+i; }) return;", SpaceAfterRequires); verifyFormat("bool b = requires (int i) { x+i; };", SpaceAfterRequires); SpaceAfterRequires.SpaceBeforeParensOptions.InRequiresClause = true; SpaceAfterRequires.SpaceBeforeParensOptions.InRequiresExpression = false; verifyFormat("void f(auto x) requires (requires(int i) { x+i; }) { }", SpaceAfterRequires); verifyFormat("if (requires(int i) { x+i; }) return;", SpaceAfterRequires); verifyFormat("bool b = requires(int i) { x+i; };", SpaceAfterRequires); SpaceAfterRequires.SpaceBeforeParensOptions.InRequiresClause = false; SpaceAfterRequires.SpaceBeforeParensOptions.InRequiresExpression = true; verifyFormat("void f(auto x) requires(requires (int i) { x+i; }) { }", SpaceAfterRequires); verifyFormat("if (requires (int i) { x+i; }) return;", SpaceAfterRequires); verifyFormat("bool b = requires (int i) { x+i; };", SpaceAfterRequires); SpaceAfterRequires.SpaceBeforeParensOptions.InRequiresClause = false; SpaceAfterRequires.SpaceBeforeParensOptions.InRequiresExpression = false; verifyFormat("void f(auto x) requires(requires(int i) { x+i; }) { }", SpaceAfterRequires); verifyFormat("if (requires(int i) { x+i; }) return;", SpaceAfterRequires); verifyFormat("bool b = requires(int i) { x+i; };", SpaceAfterRequires); |
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3999 | I get your point, but the space does not go anywhere in the clause/expression, so AfterRequiresForClauses? |
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3999 | (I'd avoid the word For, because of keyword for.) |
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3999 | My concern is: In may refer to anywhere in the clause, but we are talking about one very specific point per clause. (Analogues for expression.) The current version is very explicit, and I don't have a problem with such a long name. | |
clang/include/clang/Format/Format.h | ||
3590 | Non native here, but I think one could argue both were okay. I just copied what the other options state. |
clang/include/clang/Format/Format.h | ||
---|---|---|
3590 | It's definitely not grammatical to talk about "opening parentheses, if there is one". But if this is just copying pre-existing wording, then OK, no objection to someone handling the grammar in a followup PR. |
LGTM. My naming suggestion is not binding. I have no strong opinion on this, but a shorter name would get my 👍 :).
So please sync with other reviewers.
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
4007 | Wouldn't AfterRequiresInClause/AfterRequiresInExpression be meaningful enough? |
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
4007 | +1, I have no problem with AfterRequiresInClause and AfterRequiresInExpression! |
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
4007 | I will change the names accordingly before the commit. They are much better. |
You meant "if there is one", right?