[clang] [alpha.webkit.RetainPtrCtorAdoptChecker] Check nullity before calling IgnoreParenCasts. (PR #137556)

via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 27 15:18:47 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: Ryosuke Niwa (rniwa)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp (+2-1) 


``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
index bba1d48e6db11..34c98daa78049 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
@@ -444,9 +444,10 @@ class RetainPtrCtorAdoptChecker
       return false;
     if (!ObjCMsgExpr->isInstanceMessage())
       return false;
-    auto *Receiver = ObjCMsgExpr->getInstanceReceiver()->IgnoreParenCasts();
+    auto *Receiver = ObjCMsgExpr->getInstanceReceiver();
     if (!Receiver)
       return false;
+    Receiver = Receiver->IgnoreParenCasts();
     if (auto *Inner = dyn_cast<ObjCMessageExpr>(Receiver)) {
       if (InnerExpr)
         *InnerExpr = Inner;

``````````

</details>


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


More information about the cfe-commits mailing list