From 20982803252c1ded98536228c70709a027fe094d Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 28 Jan 2009 05:06:46 +0000 Subject: [PATCH] retain/release checker: Output the name of the function that allocates an object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63178 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/CFRefCount.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index 89169fa218..d3cf89caa4 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -2312,10 +2312,10 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, // Check if the type state has changed. const GRState* PrevSt = PrevN->getState(); - const GRState* CurrSt = N->getState(); - + GRStateRef CurrSt(N->getState(), cast(BR).getStateManager()); + RefBindings PrevB = PrevSt->get(); - RefBindings CurrB = CurrSt->get(); + RefBindings CurrB = CurrSt.get(); const RefVal* PrevT = PrevB.lookup(Sym); const RefVal* CurrT = CurrB.lookup(Sym); @@ -2332,10 +2332,17 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, Stmt* S = cast(N->getLocation()).getStmt(); if (CurrV.isOwned()) { + if (CallExpr *CE = dyn_cast(S)) { + // Get the name of the callee (if it is available). + SVal X = CurrSt.GetSVal(CE->getCallee()); - if (isa(S)) { - os << "Function call returns an object with a +1 retain count" - " (owning reference)."; + if (loc::FuncVal* FV = dyn_cast(&X)) + os << "Call to function '" << FV->getDecl()->getNameAsString() <<'\''; + else + os << "Function call"; + + os << " returns an object with a +1 retain count" + " (owning reference)."; } else { assert (isa(S)); @@ -2421,17 +2428,11 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N, // Add the range by scanning the children of the statement for any bindings // to Sym. - - GRStateManager& VSM = cast(BR).getStateManager(); - for (Stmt::child_iterator I = S->child_begin(), E = S->child_end(); I!=E; ++I) if (Expr* Exp = dyn_cast_or_null(*I)) { - SVal X = VSM.GetSVal(CurrSt, Exp); - + SVal X = CurrSt.GetSVal(Exp); if (loc::SymbolVal* SV = dyn_cast(&X)) - if (SV->getSymbol() == Sym) { - P->addRange(Exp->getSourceRange()); break; - } + if (SV->getSymbol() == Sym) P->addRange(Exp->getSourceRange()); break; } return P; -- 2.40.0