[all-commits] [llvm/llvm-project] 3b1e18: [clang-tidy] Add new check bugprone-capture-this-b...
Congcong Cai via All-commits
all-commits at lists.llvm.org
Mon Mar 17 00:12:05 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3b1e18c2dba850922bc259a258e65490058e523d
https://github.com/llvm/llvm-project/commit/3b1e18c2dba850922bc259a258e65490058e523d
Author: Congcong Cai <congcongcai0907 at 163.com>
Date: 2025-03-17 (Mon, 17 Mar 2025)
Changed paths:
M clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
M clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
A clang-tools-extra/clang-tidy/bugprone/CapturingThisInMemberVariableCheck.cpp
A clang-tools-extra/clang-tidy/bugprone/CapturingThisInMemberVariableCheck.h
M clang-tools-extra/docs/ReleaseNotes.rst
A clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst
M clang-tools-extra/docs/clang-tidy/checks/list.rst
A clang-tools-extra/test/clang-tidy/checkers/bugprone/capturing-this-in-member-variable.cpp
Log Message:
-----------
[clang-tidy] Add new check bugprone-capture-this-by-field (#130297)
Finds lambda captures that capture the ``this`` pointer and store it as
class
members without handle the copy and move constructors and the
assignments.
Capture this in a lambda and store it as a class member is dangerous
because the
lambda can outlive the object it captures. Especially when the object is
copied
or moved, the captured ``this`` pointer will be implicitly propagated to
the
new object. Most of the time, people will believe that the captured
``this``
pointer points to the new object, which will lead to bugs.
Fixes: #120863
---------
Co-authored-by: Baranov Victor <70346889+vbvictor at users.noreply.github.com>
Co-authored-by: Baranov Victor <bar.victor.2002 at gmail.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list