[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
Tue Jul 16 23:45:32 PDT 2024
================
@@ -1877,6 +1914,33 @@ 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)) {
+ const FunctionDecl *FD = CE->getDirectCallee();
+ if (!FD)
+ return;
+
+ if (FD->hasAttrs()) {
+ bool attrPrinted = false;
+
+ for (const auto *I : FD->specific_attrs<OwnershipAttr>()) {
+ OwnershipAttr::OwnershipKind OwnKind = I->getOwnKind();
+
+ if (OwnKind == OwnershipAttr::Takes) {
+ if (attrPrinted)
+ os << ", ";
+ else
+ os << ", which takes ownership of ";
+
+ os << '\'' << I->getModule()->getName() << "'";
----------------
steakhal wrote:
You use single quoted char and double quoted char. I just highlight this inconsistency.
https://github.com/llvm/llvm-project/pull/98941
More information about the cfe-commits
mailing list