[all-commits] [llvm/llvm-project] 05860f: [WebKit checkers] Recognize ensureFoo functions (#...

Ryosuke Niwa via All-commits all-commits at lists.llvm.org
Fri Dec 13 01:48:50 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 05860f9b384b9b8f8bb01fa8984dbc2833669a27
      https://github.com/llvm/llvm-project/commit/05860f9b384b9b8f8bb01fa8984dbc2833669a27
  Author: Ryosuke Niwa <rniwa at webkit.org>
  Date:   2024-12-13 (Fri, 13 Dec 2024)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
    M clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
    M clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
    M clang/test/Analysis/Checkers/WebKit/call-args-checked-const-member.cpp
    M clang/test/Analysis/Checkers/WebKit/call-args-checked-ptr.cpp
    M clang/test/Analysis/Checkers/WebKit/call-args-counted-const-member.cpp
    M clang/test/Analysis/Checkers/WebKit/call-args.cpp
    M clang/test/Analysis/Checkers/WebKit/local-vars-checked-const-member.cpp
    M clang/test/Analysis/Checkers/WebKit/local-vars-counted-const-member.cpp
    M clang/test/Analysis/Checkers/WebKit/mock-types.h

  Log Message:
  -----------
  [WebKit checkers] Recognize ensureFoo functions (#119681)

In WebKit, we often write Foo::ensureBar function which lazily
initializes m_bar and returns a raw pointer or a raw reference to m_bar.
Such a return value is safe to use for the duration of a member function
call in Foo so long as m_bar is const so that it never gets unset or
updated with a new value once it's initialized.

This PR adds support for recognizing these types of functions and
treating its return value as a safe origin of a function argument
(including "this") or a local variable.



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