[clang] [alpha.webkit.UncountedLocalVarsChecker] Don't treat a call through a raw pointer/reference guardian argument as a mutation (PR #225309)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 21 23:50:02 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Fady Farag (iidmsa)

<details>
<summary>Changes</summary>

Previously, when a function parameter was used as the guardian of a raw pointer/reference local, `GuardianVisitor` treated any non-const member function call on the parameter, or passing it to a non-const parameter, as a mutation. That is correct for a `RefPtr<T>&` parameter but not for a raw pointer/reference parameter, where such a call operates on the pointee and cannot change the parameter, which caused an unnecessary warning whenever the parameter was used at all. This only treats a raw pointer/reference guardian argument as mutated when it is assigned to, or when the callee can reseat it by receiving it as `Bar*&` or `Bar**`.

---
Full diff: https://github.com/llvm/llvm-project/pull/225309.diff


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp (+32-10) 
- (modified) clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp (+84) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


https://github.com/llvm/llvm-project/pull/225309


More information about the cfe-commits mailing list