From c537a6d3f1e1965fc2473fa2501cdb454cad17a1 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 20 Feb 2009 00:05:35 +0000 Subject: [PATCH] Fix crash from : 'init' method only return a receiver alias if the return type is a location. llvm-svn: 65084 --- clang/lib/Analysis/CFRefCount.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index 36c1b79af317..8e120afecc26 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -915,8 +915,11 @@ RetainSummary* RetainSummaryManager::getInitMethodSummary(ObjCMessageExpr* ME) { assert(ScratchArgs.empty()); + // 'init' methods only return an alias if the return type is a location type. + QualType T = ME->getType(); RetainSummary* Summ = - getPersistentSummary(RetEffect::MakeReceiverAlias()); + getPersistentSummary(Loc::IsLocType(T) ? RetEffect::MakeReceiverAlias() + : RetEffect::MakeNoRet()); ObjCMethodSummaries[ME] = Summ; return Summ; @@ -1608,7 +1611,7 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, unsigned Count = Builder.getCurrentBlockCount(); SymbolRef Sym = Eng.getSymbolManager().getConjuredSymbol(Ex, Count); - SVal X = Loc::IsLocType(Ex->getType()) + SVal X = Loc::IsLocType(T) ? cast(loc::SymbolVal(Sym)) : cast(nonloc::SymbolVal(Sym));