[clang] [Clang SA]: add support for mismatched ownership_returns+ownership_takes calls for custom allocation classes (PR #98941)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 17 21:58:17 PDT 2024


================
@@ -1877,16 +1923,43 @@ static bool didPreviousFreeFail(ProgramStateRef State,
   return false;
 }
 
+static void printOwnershipTakesList(raw_ostream &os, CheckerContext &C,
+                                    const Expr *E) {
+  if (const CallExpr *CE = dyn_cast<CallExpr>(E)) {
----------------
steakhal wrote:

When I advocated for early-returns, I wanted something like this:
```c++
const auto *CE = dyn_cast<CallExpr>(E);
if (!CE)
  return;
const FunctionDecl *FD = CE->getDirectCallee();
if (!FD)
  return;
  ...
```
On the same token, the `FD->hasAttrs()` appears to be not strictly necessary as in that case the loop simply wouldn't take any iterations at all, right?

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


More information about the cfe-commits mailing list