[clang] Add warning for blocks capturing {'this', raw pointers, references} (PR #144388)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 16 17:59:13 PDT 2025
================
@@ -1641,6 +1641,17 @@ def warn_implicitly_retains_self : Warning <
"block implicitly retains 'self'; explicitly mention 'self' to indicate "
"this is intended behavior">,
InGroup<DiagGroup<"implicit-retain-self">>, DefaultIgnore;
+def warn_blocks_capturing_this : Warning<"block implicitly captures 'this'">,
+ InGroup<DiagGroup<"blocks-capturing-this">>,
+ DefaultIgnore;
+def warn_blocks_capturing_reference
+ : Warning<"block implicitly captures a C++ reference">,
+ InGroup<DiagGroup<"blocks-capturing-reference">>,
+ DefaultIgnore;
+def warn_blocks_capturing_raw_pointer
+ : Warning<"block implicitly captures a raw pointer">,
+ InGroup<DiagGroup<"blocks-capturing-raw-pointer">>,
+ DefaultIgnore;
----------------
rjmccall wrote:
There's an existing `block-capture-autoreleasing` warning group that's probably the right pattern for these group names.
We can also create a diagnostic group that includes all of these warnings. I'm not sure if that's a good idea because of my concerns above, but I state it for completeness.
https://github.com/llvm/llvm-project/pull/144388
More information about the cfe-commits
mailing list