This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] add check for capturing lambda coroutines
ClosedPublic

Authored by PiotrZSL on Nov 6 2022, 4:42 PM.

Details

Summary

Signed-off-by: Noah Watkins <noah@redpanda.com>

Diff Detail

Event Timeline

dotnwat created this revision.Nov 6 2022, 4:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 4:42 PM
dotnwat requested review of this revision.Nov 6 2022, 4:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 4:42 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dotnwat added a reviewer: Restricted Project.Nov 6 2022, 4:43 PM

This is helpful. I feel it is OK to add the warning in the clang too. Are you interested in that?

This is helpful. I feel it is OK to add the warning in the clang too. Are you interested in that?

Yes, but unfortunately I'm very time constrained until the end of the year. Is that something that would need to be added to this diff, or could be separate? (fyi, brand new to clang development)

This is helpful. I feel it is OK to add the warning in the clang too. Are you interested in that?

Yes, but unfortunately I'm very time constrained until the end of the year. Is that something that would need to be added to this diff, or could be separate? (fyi, brand new to clang development)

Oh, I am not blocking this patch and this patch looks good to me and self-contained. That's just a simple suggestion.

carlosgalvezp requested changes to this revision.Dec 13 2022, 7:21 AM

Looking good! Some minor comments

clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCapturingLambdaCoroutinesCheck.cpp
41

Perhaps it would be good with a diagnostic that gives more actionable feedback? For example "avoid capturing coroutines in a lambda"

clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCapturingLambdaCoroutinesCheck.h
19

Start the documentation describing "what" the check warns for (here you explain the "why"). Make sure this text is in sync with the .rst documentation.

29

Limit to C++20 using isLanguageVersionSupported

clang-tools-extra/docs/ReleaseNotes.rst
126

C++ Core Guidelines

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-capturing-lambda-coroutines.rst
23 ↗(On Diff #473522)

Mention that the check implements rule CP.51 of C++ Core Guidelines, and add a link to the that guideline (see other C++ Core Guidelines checks as an example).

24 ↗(On Diff #473522)

does

clang-tools-extra/docs/clang-tidy/checks/list.rst
182

Remove, since this check does not provide fix-its.

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-capturing-lambda-coroutines.cpp
1–2 ↗(On Diff #473522)

I think it's easier to read and reason about if you keep it in one line.

2 ↗(On Diff #473522)

It's strange to have this test depend on input data from another module - create a Inputs folder inside the cppcoreguidelines folder and copy coroutines.h there.

This revision now requires changes to proceed.Dec 13 2022, 7:21 AM
carlosgalvezp added inline comments.Dec 13 2022, 7:22 AM
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCapturingLambdaCoroutinesCheck.cpp
41

I meant to remove this comment since it's rather nitpick, please ignore :)

Is there any new progress on this?

PiotrZSL updated this revision to Diff 503888.Mar 9 2023, 12:47 PM

Rebase + Move files to other locations due to structure change

PiotrZSL updated this revision to Diff 503939.Mar 9 2023, 2:43 PM

Making tests passing on this diff

ChuanqiXu accepted this revision.Mar 9 2023, 6:09 PM

LGTM. Thanks! BTW, in such cases, you can commandeer the revision generally.

PiotrZSL commandeered this revision.Mar 9 2023, 10:55 PM
PiotrZSL added a reviewer: dotnwat.
PiotrZSL marked 5 inline comments as done.
PiotrZSL marked an inline comment as done.
This revision was not accepted when it landed; it landed in state Needs Review.Mar 10 2023, 6:07 AM
This revision was automatically updated to reflect the committed changes.