serenity
serenity copied to clipboard
ClangPlugins: Invert lambda capture mechanism; Emit errors instead of warning
This also removes the IGNORE_USE_IN_ESCAPING_LAMBDA annotation in favor of a DOES_NOT_OUTLIVE_CAPTURES annotation that is applied directly to the lambda instead of to each individual capture declaration.
I also added a FixIt hint for one of the errors:
Soft depends on #24350, as otherwise those issues will be flagged as errors and fail the build, but that technically doesn't matter until this is integrated in CI
Looks like clang-format can't handle the C++23 lambda attributes if they're macro identifiers unfortunately, so that change will have to wait
Looks like clang-format can't handle the C++23 lambda attributes if they're macro identifiers unfortunately, so that change will have to wait
I just filed https://github.com/llvm/llvm-project/issues/92657 -- is this that same bug?
I just filed https://github.com/llvm/llvm-project/issues/92657 -- is this that same bug?
Maybe? Depends on what that annotation is applied to. This bug is related to the annotations introduced in P2173R1, which apply directly to the operator() of the lambda, like in this snippet:
#define ATTR [[clang::annotate("attr")]]
void foo()
{
auto lambda = [] ATTR (int& arg) {};
}
I know annotations that appear after the return type apply to that type, but I'm not sure about annotations that are applied before the return type. If this is the same thing then I'll just use the style you used instead (though what does the annotation apply to if there is no return clause at all?)
e: Nope, different issue:
❯ clang test.cpp -std=c++23
test.cpp:4:33: error: 'annotate' attribute cannot be applied to types
4 | auto lambda = [] (int& arg) ATTR {};
| ^
test.cpp:1:16: note: expanded from macro 'ATTR'
1 | #define ATTR [[clang::annotate("attr")]]
| ^
1 error generated.
ref: llvm/llvm-project#92661
Hello!
One or more of the commit messages in this PR do not match the SerenityOS code submission policy, please check the lint_commits CI job for more details on which commits were flagged and why.
Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR.