[all-commits] [llvm/llvm-project] 5409fb: [clang-format] Annotate lambdas with requires clau...
Emilia Dreamer via All-commits
all-commits at lists.llvm.org
Sat Mar 25 18:42:53 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5409fb38372dbf65a94725ccefab2b993fbb7a9b
https://github.com/llvm/llvm-project/commit/5409fb38372dbf65a94725ccefab2b993fbb7a9b
Author: Emilia Dreamer <emilia at rymiel.space>
Date: 2023-03-26 (Sun, 26 Mar 2023)
Changed paths:
M clang/lib/Format/UnwrappedLineParser.cpp
M clang/unittests/Format/TokenAnnotatorTest.cpp
Log Message:
-----------
[clang-format] Annotate lambdas with requires clauses.
The C++ grammar allows lambdas to have a *requires-clause* in two
places, either directly after the *template-parameter-list*, such as:
`[] <typename T> requires foo<T> (T t) { ... };`
Or, at the end of the *lambda-declarator* (before the lambda's body):
`[] <typename T> (T t) requires foo<T> { ... };`
Previously, these cases weren't handled at all, resulting in weird
results.
Note that this commit only handles token annotation, so the actual
formatting still ends up suboptimal. This is mostly because I do not yet
know how to approach making the requires clause formatting of lambdas
match the formatting for functions.
Fixes https://github.com/llvm/llvm-project/issues/61269
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D145642
Commit: a8d2bff290e1b86b4bca4007493205b4878c4f68
https://github.com/llvm/llvm-project/commit/a8d2bff290e1b86b4bca4007493205b4878c4f68
Author: Emilia Dreamer <emilia at rymiel.space>
Date: 2023-03-26 (Sun, 26 Mar 2023)
Changed paths:
M clang/lib/Format/TokenAnnotator.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Don't wrap struct return types as structs
When using BraceWrapping.AfterClass or BraceWrapping.AfterStruct, the
token annotator relies on the first token of the line to determine if
we're dealing with a struct or class, however, this check is faulty if
it's actually a function with an elaborated struct/class return type, as
is common in C.
This patch skips the check if the brace is already annotated as
FunctionLBrace, in which case we already know it's a function and should
be treated as such.
Fixes https://github.com/llvm/llvm-project/issues/58527
Reviewed By: HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D146281
Commit: bb4f6c4dca98a47054117708015bb2724256ee83
https://github.com/llvm/llvm-project/commit/bb4f6c4dca98a47054117708015bb2724256ee83
Author: Emilia Dreamer <emilia at rymiel.space>
Date: 2023-03-26 (Sun, 26 Mar 2023)
Changed paths:
M clang/lib/Format/TokenAnnotator.cpp
M clang/unittests/Format/TokenAnnotatorTest.cpp
Log Message:
-----------
[clang-format] Treat NTTP default values as expressions
clang-format already has logic to threat the right-hand side of an
equals sign. This patch applies that logic to template defaults,
which are likely to be non-template type parameters in which case the
default value should be annotated as an expression.
This should mostly only ever apply to bool and &&.
Fixes https://github.com/llvm/llvm-project/issues/61664
Reviewed By: MyDeveloperDay, owenpan
Differential Revision: https://reviews.llvm.org/D146760
Compare: https://github.com/llvm/llvm-project/compare/cd67bbdc2496...bb4f6c4dca98
More information about the All-commits
mailing list