[clang] [alpha.webkit.UnretainedCallArgsChecker] Recognize [allocObj() init] pattern (PR #161019)
Ryosuke Niwa via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 9 12:23:45 PST 2025
================
@@ -321,6 +321,51 @@ bool isExprToGetCheckedPtrCapableMember(const clang::Expr *E) {
return result && *result;
}
+bool isAllocInit(const Expr *E, const Expr **InnerExpr) {
+ auto *ObjCMsgExpr = dyn_cast<ObjCMessageExpr>(E);
+ if (auto *POE = dyn_cast<PseudoObjectExpr>(E)) {
+ if (unsigned ExprCount = POE->getNumSemanticExprs()) {
+ auto *Expr = POE->getSemanticExpr(ExprCount - 1)->IgnoreParenCasts();
----------------
rniwa wrote:
Right, and here too we check that `POE->getNumSemanticExprs()`'s return value is at least 1 by the if:
```cpp
if (unsigned ExprCount = POE->getNumSemanticExprs()) {
// ExprCount is at least 1 here or else the above if condition will evaluate to false.
auto *Expr = POE->getSemanticExpr(ExprCount - 1)->IgnoreParenCasts();
```
https://github.com/llvm/llvm-project/pull/161019
More information about the cfe-commits
mailing list