This is an archive of the discontinued LLVM Phabricator instance.

[clang] Warn by default that implicit capture of 'this' is deprecated in C++20 and later.
ClosedPublic

Authored by tahonermann on Jan 26 2023, 7:59 AM.

Details

Summary

Previously, a warning that C++20 deprecated implicit capture of 'this' for lambda captures specified with a capture default of '=' was only issued when '-Wdeprecated' or '-Wdeprecated-this-capture' was specified. This change enables the warning by default (it is still only issued when compiling for C++20 or later). This is consistent with gcc which warns by default (MSVC requires '/Wall').

Diff Detail

Event Timeline

tahonermann created this revision.Jan 26 2023, 7:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 7:59 AM
tahonermann requested review of this revision.Jan 26 2023, 7:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2023, 7:59 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
erichkeane accepted this revision.Jan 26 2023, 8:03 AM
erichkeane added a subscriber: royjacobson.

You'll need a rebase to get the pre-commit CI to work. Else, looks fine to me. Make sure @royjacobson knows of the change for this (https://reviews.llvm.org/D142578).

This revision is now accepted and ready to land.Jan 26 2023, 8:03 AM

You'll need a rebase to get the pre-commit CI to work.

Yes, thank you. I'll wait for https://reviews.llvm.org/D142578 to land and then rebase.

shafik accepted this revision.Jan 26 2023, 1:45 PM

LGTM

Rebased. This now targets Clang 17.