-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClangPlugins: Invert lambda capture mechanism; Emit errors instead of warning #24361
ClangPlugins: Invert lambda capture mechanism; Emit errors instead of warning #24361
Conversation
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 llvm/llvm-project#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 #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:
|
3dad58f
to
d005c3b
Compare
9db16d5
to
5e50f31
Compare
Hello! One or more of the commit messages in this PR do not match the SerenityOS code submission policy, please check the |
5e50f31
to
97d73eb
Compare
See the next commit for an explanation
Instead of being opt-out with NOESCAPE, it is now opt-in with ESCAPING. Opt-out is ideal, but unfortunately this was extremely noisy when compiling the entire codebase. Escaping functions are rarer than non- escaping ones, so let's just go with that for now. This also allows us to gradually add heuristics for detecting missing ESCAPING annotations and emitting them as errors. It also nicely matches the spelling that Swift uses (@escaping), which is where this idea originally came from.
This isn't comprehensive; just a result of a simple grep search.
Now that the lambda capture plugin isn't full of false-positives, we can make the jump and start halting builds for these errors. It also allows these plugins to be useful in CI.
97d73eb
to
2f85118
Compare
This also removes the
IGNORE_USE_IN_ESCAPING_LAMBDA
annotation in favor of aDOES_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