[all-commits] [llvm/llvm-project] 16e5c3: [alpha.webkit.RetainPtrCtorAdoptChecker] An assort...

Ryosuke Niwa via All-commits all-commits at lists.llvm.org
Sun Apr 27 14:24:53 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 16e5c3ddadaa8d25698a71c0308b1d0ca887d11f
      https://github.com/llvm/llvm-project/commit/16e5c3ddadaa8d25698a71c0308b1d0ca887d11f
  Author: Ryosuke Niwa <rniwa at webkit.org>
  Date:   2025-04-27 (Sun, 27 Apr 2025)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
    M clang/test/Analysis/Checkers/WebKit/objc-mock-types.h
    M clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use-arc.mm
    M clang/test/Analysis/Checkers/WebKit/retain-ptr-ctor-adopt-use.mm

  Log Message:
  -----------
  [alpha.webkit.RetainPtrCtorAdoptChecker] An assortment of small enhancements (#135329)

This PR implements various small enhancements to
alpha.webkit.RetainPtrCtorAdoptChecker:
 - Detect leaks from [[X alloc] init] when ARC is disabled.
 - Detect leaks from calling Create, Copy, and other +1 CF functions.
 - Recognize [allocX() init] pattern where allocX is a C/C++ function.
 - Recognize _init in addition to init as an init function.
 - Recognize [[[X alloc] init] autorelease].
 - Recognize CFBridgingRelease.
 - Support CF_RETRUNS_RETAINED on out arguments of a C function.
- Support returning +1 object in Create, Copy, and other +1 functions or
+1 selectors.
 - Support variadic Create, Copy, and other +1 C/C++ functions.

To make these enhancements, this PR introduces new visit functions for
ObjCMessageExpr, ReturnStmt, VarDecl, and BinaryOperator. These
functions look for a specific construct mentioned above and adds an
expression such as [[X alloc] init] or CreateX to a DenseSet
CreateOrCopyFnCall when the expression does not result in leaks. When
the code to detect leaks such as the one in visitObjCMessageExpr later
encounters this expression, it can bail out early if the expression is
in the set.



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