Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h =================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h +++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h @@ -65,10 +65,6 @@ /// if CFRetain has been called on the argument. IncRef, - /// The argument acts as if has been passed to CFMakeCollectable, which - /// transfers the object to the Garbage Collector under GC. - MakeCollectable, - /// The argument is a pointer to a retain-counted object; on exit, the new /// value of the pointer is a +0 value or NULL. UnretainedOutParameter, Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -83,14 +83,12 @@ ReturnedNotOwned, // Return object does not pass ownership to caller. ERROR_START, ErrorDeallocNotOwned, // -dealloc called on non-owned object. - ErrorDeallocGC, // Calling -dealloc with GC enabled. ErrorUseAfterRelease, // Object used after released. ErrorReleaseNotOwned, // Release of an object that was not owned. ERROR_LEAK_START, ErrorLeak, // A memory leak due to excessive reference counts. ErrorLeakReturned, // A memory leak due to the returning method not having // the correct naming conventions. - ErrorGCLeakReturned, ErrorOverAutorelease, ErrorReturnedNotOwned }; @@ -303,10 +301,6 @@ Out << "Released"; break; - case ErrorDeallocGC: - Out << "-dealloc (GC)"; - break; - case ErrorDeallocNotOwned: Out << "-dealloc (not-owned)"; break; @@ -319,10 +313,6 @@ Out << "Leaked (Bad naming)"; break; - case ErrorGCLeakReturned: - Out << "Leaked (GC-ed at return)"; - break; - case ErrorUseAfterRelease: Out << "Use-After-Release [ERROR]"; break; @@ -600,9 +590,6 @@ /// Ctx - The ASTContext object for the analyzed ASTs. ASTContext &Ctx; - /// GCEnabled - Records whether or not the analyzed code runs in GC mode. - const bool GCEnabled; - /// Records whether or not the analyzed code runs in ARC mode. const bool ARCEnabled; @@ -646,7 +633,7 @@ /// data in ScratchArgs. ArgEffects getArgEffects(); - enum UnaryFuncKind { cfretain, cfrelease, cfautorelease, cfmakecollectable }; + enum UnaryFuncKind { cfretain, cfrelease, cfautorelease }; const RetainSummary *getUnarySummary(const FunctionType* FT, UnaryFuncKind func); @@ -732,19 +719,14 @@ public: - RetainSummaryManager(ASTContext &ctx, bool gcenabled, bool usesARC) + RetainSummaryManager(ASTContext &ctx, bool usesARC) : Ctx(ctx), - GCEnabled(gcenabled), ARCEnabled(usesARC), AF(BPAlloc), ScratchArgs(AF.getEmptyMap()), - ObjCAllocRetE(gcenabled - ? RetEffect::MakeGCNotOwned() - : (usesARC ? RetEffect::MakeNotOwned(RetEffect::ObjC) - : RetEffect::MakeOwned(RetEffect::ObjC))), - ObjCInitRetE(gcenabled - ? RetEffect::MakeGCNotOwned() - : (usesARC ? RetEffect::MakeNotOwned(RetEffect::ObjC) - : RetEffect::MakeOwnedWhenTrackedReceiver())) { + ObjCAllocRetE(usesARC ? RetEffect::MakeNotOwned(RetEffect::ObjC) + : RetEffect::MakeOwned(RetEffect::ObjC)), + ObjCInitRetE(usesARC ? RetEffect::MakeNotOwned(RetEffect::ObjC) + : RetEffect::MakeOwnedWhenTrackedReceiver()) { InitializeClassMethodSummaries(); InitializeMethodSummaries(); } @@ -802,12 +784,8 @@ void updateSummaryForCall(const RetainSummary *&Summ, const CallEvent &Call); - bool isGCEnabled() const { return GCEnabled; } - bool isARCEnabled() const { return ARCEnabled; } - bool isARCorGCEnabled() const { return GCEnabled || ARCEnabled; } - RetEffect getObjAllocRetEffect() const { return ObjCAllocRetE; } friend class RetainSummaryTemplate; @@ -895,12 +873,6 @@ FName.endswith_lower("autorelease"); } -static bool isMakeCollectable(const FunctionDecl *FD, StringRef FName) { - // FIXME: Remove FunctionDecl parameter. - // FIXME: Is it really okay if MakeCollectable isn't a suffix? - return FName.find_lower("MakeCollectable") != StringRef::npos; -} - static ArgEffect getStopTrackingHardEquivalent(ArgEffect E) { switch (E) { case DoNothing: @@ -908,7 +880,6 @@ case DecRefBridgedTransferred: case IncRef: case IncRefMsg: - case MakeCollectable: case UnretainedOutParameter: case RetainedOutParameter: case MayEscape: @@ -1073,14 +1044,6 @@ // Part of: and . // This will be addressed better with IPA. S = getPersistentStopSummary(); - } else if (FName == "NSMakeCollectable") { - // Handle: id NSMakeCollectable(CFTypeRef) - S = (RetTy->isObjCIdType()) - ? getUnarySummary(FT, cfmakecollectable) - : getPersistentStopSummary(); - // The headers on OS X 10.8 use cf_consumed/ns_returns_retained, - // but we can fully model NSMakeCollectable ourselves. - AllowAnnotations = false; } else if (FName == "CFPlugInInstanceCreate") { S = getPersistentSummary(RetEffect::MakeNoRet()); } else if (FName == "IORegistryEntrySearchCFProperty" @@ -1181,9 +1144,6 @@ // The headers use cf_consumed, but we can fully model CFAutorelease // ourselves. AllowAnnotations = false; - } else if (isMakeCollectable(FD, FName)) { - S = getUnarySummary(FT, cfmakecollectable); - AllowAnnotations = false; } else { S = getCFCreateGetRuleSummary(FD); } @@ -1294,7 +1254,6 @@ case cfretain: Effect = IncRef; break; case cfrelease: Effect = DecRef; break; case cfautorelease: Effect = Autorelease; break; - case cfmakecollectable: Effect = MakeCollectable; break; } ScratchArgs = AF.add(ScratchArgs, 0, Effect); @@ -1732,16 +1691,6 @@ } }; - class DeallocGC : public CFRefBug { - public: - DeallocGC(const CheckerBase *checker) - : CFRefBug(checker, "-dealloc called while using garbage collection") {} - - const char *getDescription() const override { - return "-dealloc called while using garbage collection"; - } - }; - class DeallocNotOwned : public CFRefBug { public: DeallocNotOwned(const CheckerBase *checker) @@ -1792,11 +1741,10 @@ protected: SymbolRef Sym; const SummaryLogTy &SummaryLog; - bool GCEnabled; public: - CFRefReportVisitor(SymbolRef sym, bool gcEnabled, const SummaryLogTy &log) - : Sym(sym), SummaryLog(log), GCEnabled(gcEnabled) {} + CFRefReportVisitor(SymbolRef sym, const SummaryLogTy &log) + : Sym(sym), SummaryLog(log) {} void Profile(llvm::FoldingSetNodeID &ID) const override { static int x = 0; @@ -1816,9 +1764,9 @@ class CFRefLeakReportVisitor : public CFRefReportVisitor { public: - CFRefLeakReportVisitor(SymbolRef sym, bool GCEnabled, + CFRefLeakReportVisitor(SymbolRef sym, const SummaryLogTy &log) - : CFRefReportVisitor(sym, GCEnabled, log) {} + : CFRefReportVisitor(sym, log) {} std::shared_ptr getEndPath(BugReporterContext &BRC, const ExplodedNode *N, @@ -1826,24 +1774,21 @@ }; class CFRefReport : public BugReport { - void addGCModeDescription(const LangOptions &LOpts, bool GCEnabled); public: - CFRefReport(CFRefBug &D, const LangOptions &LOpts, bool GCEnabled, + CFRefReport(CFRefBug &D, const LangOptions &LOpts, const SummaryLogTy &Log, ExplodedNode *n, SymbolRef sym, bool registerVisitor = true) : BugReport(D, D.getDescription(), n) { if (registerVisitor) - addVisitor(llvm::make_unique(sym, GCEnabled, Log)); - addGCModeDescription(LOpts, GCEnabled); + addVisitor(llvm::make_unique(sym, Log)); } - CFRefReport(CFRefBug &D, const LangOptions &LOpts, bool GCEnabled, + CFRefReport(CFRefBug &D, const LangOptions &LOpts, const SummaryLogTy &Log, ExplodedNode *n, SymbolRef sym, StringRef endText) : BugReport(D, D.getDescription(), endText, n) { - addVisitor(llvm::make_unique(sym, GCEnabled, Log)); - addGCModeDescription(LOpts, GCEnabled); + addVisitor(llvm::make_unique(sym, Log)); } llvm::iterator_range getRanges() override { @@ -1863,10 +1808,10 @@ // Finds the location where a leak warning for 'sym' should be raised. void deriveAllocLocation(CheckerContext &Ctx, SymbolRef sym); // Produces description of a leak warning which is printed on the console. - void createDescription(CheckerContext &Ctx, bool GCEnabled, bool IncludeAllocationLine); + void createDescription(CheckerContext &Ctx, bool IncludeAllocationLine); public: - CFRefLeakReport(CFRefBug &D, const LangOptions &LOpts, bool GCEnabled, + CFRefLeakReport(CFRefBug &D, const LangOptions &LOpts, const SummaryLogTy &Log, ExplodedNode *n, SymbolRef sym, CheckerContext &Ctx, bool IncludeAllocationLine); @@ -1878,39 +1823,6 @@ }; } // end anonymous namespace -void CFRefReport::addGCModeDescription(const LangOptions &LOpts, - bool GCEnabled) { - const char *GCModeDescription = nullptr; - - switch (LOpts.getGC()) { - case LangOptions::GCOnly: - assert(GCEnabled); - GCModeDescription = "Code is compiled to only use garbage collection"; - break; - - case LangOptions::NonGC: - assert(!GCEnabled); - GCModeDescription = "Code is compiled to use reference counts"; - break; - - case LangOptions::HybridGC: - if (GCEnabled) { - GCModeDescription = "Code is compiled to use either garbage collection " - "(GC) or reference counts (non-GC). The bug occurs " - "with GC enabled"; - break; - } else { - GCModeDescription = "Code is compiled to use either garbage collection " - "(GC) or reference counts (non-GC). The bug occurs " - "in non-GC mode"; - break; - } - } - - assert(GCModeDescription && "invalid/unknown GC mode"); - addExtraText(GCModeDescription); -} - static bool isNumericLiteralExpression(const Expr *E) { // FIXME: This set of cases was copied from SemaExprObjC. return isa(E) || @@ -2047,14 +1959,7 @@ if (CurrV.isOwned()) { os << "+1 retain count"; - - if (GCEnabled) { - assert(CurrV.getObjKind() == RetEffect::CF); - os << ". " - "Core Foundation objects are not automatically garbage collected."; - } - } - else { + } else { assert (CurrV.isNotOwned()); os << "+0 retain count"; } @@ -2091,14 +1996,14 @@ // We have an argument. Get the effect! AEffects.push_back(Summ->getArg(i)); } - } - else if (const ObjCMessageExpr *ME = dyn_cast(S)) { - if (const Expr *receiver = ME->getInstanceReceiver()) + } else if (const ObjCMessageExpr *ME = dyn_cast(S)) { + if (const Expr *receiver = ME->getInstanceReceiver()) { if (CurrSt->getSValAsScalarOrLoc(receiver, LCtx) .getAsLocSymbol() == Sym) { // The symbol we are tracking is the receiver. AEffects.push_back(Summ->getReceiverEffect()); } + } } } @@ -2107,7 +2012,7 @@ RefVal PrevV = *PrevT; // Specially handle -dealloc. - if (!GCEnabled && std::find(AEffects.begin(), AEffects.end(), Dealloc) != + if (std::find(AEffects.begin(), AEffects.end(), Dealloc) != AEffects.end()) { // Determine if the object's reference count was pushed to zero. assert(!PrevV.hasSameState(CurrV) && "The state should have changed."); @@ -2120,41 +2025,6 @@ } } - // Specially handle CFMakeCollectable and friends. - if (std::find(AEffects.begin(), AEffects.end(), MakeCollectable) != - AEffects.end()) { - // Get the name of the function. - const Stmt *S = N->getLocation().castAs().getStmt(); - SVal X = - CurrSt->getSValAsScalarOrLoc(cast(S)->getCallee(), LCtx); - const FunctionDecl *FD = X.getAsFunctionDecl(); - - if (GCEnabled) { - // Determine if the object's reference count was pushed to zero. - assert(!PrevV.hasSameState(CurrV) && "The state should have changed."); - - os << "In GC mode a call to '" << *FD - << "' decrements an object's retain count and registers the " - "object with the garbage collector. "; - - if (CurrV.getKind() == RefVal::Released) { - assert(CurrV.getCount() == 0); - os << "Since it now has a 0 retain count the object can be " - "automatically collected by the garbage collector."; - } - else - os << "An object must have a 0 retain count to be garbage collected. " - "After this call its retain count is +" << CurrV.getCount() - << '.'; - } - else - os << "When GC is not enabled a call to '" << *FD - << "' has no effect on its argument."; - - // Nothing more to say. - break; - } - // Determine if the typestate has changed. if (!PrevV.hasSameState(CurrV)) switch (CurrV.getKind()) { @@ -2178,12 +2048,6 @@ if (unsigned Count = CurrV.getCount()) os << " The object now has a +" << Count << " retain count."; - if (PrevV.getKind() == RefVal::Released) { - assert(GCEnabled && CurrV.getCount() > 0); - os << " The object is not eligible for garbage collection until " - "the retain count reaches 0 again."; - } - break; case RefVal::Released: @@ -2211,26 +2075,6 @@ default: return nullptr; } - - // Emit any remaining diagnostics for the argument effects (if any). - for (SmallVectorImpl::iterator I=AEffects.begin(), - E=AEffects.end(); I != E; ++I) { - - // A bunch of things have alternate behavior under GC. - if (GCEnabled) - switch (*I) { - default: break; - case Autorelease: - os << "In GC mode an 'autorelease' has no effect."; - continue; - case IncRefMsg: - os << "In GC mode the 'retain' message has no effect."; - continue; - case DecRefMsg: - os << "In GC mode the 'release' message has no effect."; - continue; - } - } } while (0); if (os.str().empty()) @@ -2437,14 +2281,6 @@ } } } - else if (RV->getKind() == RefVal::ErrorGCLeakReturned) { - const ObjCMethodDecl &MD = cast(EndN->getCodeDecl()); - os << " and returned from method '" << MD.getSelector().getAsString() - << "' is potentially leaked when using garbage collection. Callers " - "of this method do not expect a returned object with a +1 retain " - "count since they expect the object to be managed by the garbage " - "collector"; - } else os << " is not referenced later in this execution path and has a retain " "count of +" << RV->getCount(); @@ -2512,15 +2348,12 @@ UniqueingDecl = AllocNode->getLocationContext()->getDecl(); } -void CFRefLeakReport::createDescription(CheckerContext &Ctx, bool GCEnabled, +void CFRefLeakReport::createDescription(CheckerContext &Ctx, bool IncludeAllocationLine) { assert(Location.isValid() && UniqueingDecl && UniqueingLocation.isValid()); Description.clear(); llvm::raw_string_ostream os(Description); - os << "Potential leak "; - if (GCEnabled) - os << "(when using garbage collection) "; - os << "of an object"; + os << "Potential leak of an object"; Optional RegionDescription = describeRegion(AllocBinding); if (RegionDescription) { @@ -2533,19 +2366,19 @@ } CFRefLeakReport::CFRefLeakReport(CFRefBug &D, const LangOptions &LOpts, - bool GCEnabled, const SummaryLogTy &Log, + const SummaryLogTy &Log, ExplodedNode *n, SymbolRef sym, CheckerContext &Ctx, bool IncludeAllocationLine) - : CFRefReport(D, LOpts, GCEnabled, Log, n, sym, false) { + : CFRefReport(D, LOpts, Log, n, sym, false) { deriveAllocLocation(Ctx, sym); if (!AllocBinding) deriveParamLocation(Ctx, sym); - createDescription(Ctx, GCEnabled, IncludeAllocationLine); + createDescription(Ctx, IncludeAllocationLine); - addVisitor(llvm::make_unique(sym, GCEnabled, Log)); + addVisitor(llvm::make_unique(sym, Log)); } //===----------------------------------------------------------------------===// @@ -2571,10 +2404,9 @@ eval::Assume, eval::Call > { mutable std::unique_ptr useAfterRelease, releaseNotOwned; - mutable std::unique_ptr deallocGC, deallocNotOwned; + mutable std::unique_ptr deallocNotOwned; mutable std::unique_ptr overAutorelease, returnNotOwnedForOwned; mutable std::unique_ptr leakWithinFunction, leakAtReturn; - mutable std::unique_ptr leakWithinFunctionGC, leakAtReturnGC; typedef llvm::DenseMap SymbolTagMap; @@ -2582,7 +2414,6 @@ mutable SymbolTagMap DeadSymbolTags; mutable std::unique_ptr Summaries; - mutable std::unique_ptr SummariesGC; mutable SummaryLogTy SummaryLog; mutable bool ShouldResetSummaryLog; @@ -2633,72 +2464,31 @@ ShouldResetSummaryLog = !SummaryLog.empty(); } - CFRefBug *getLeakWithinFunctionBug(const LangOptions &LOpts, - bool GCEnabled) const { - if (GCEnabled) { - if (!leakWithinFunctionGC) - leakWithinFunctionGC.reset(new Leak(this, "Leak of object when using " - "garbage collection")); - return leakWithinFunctionGC.get(); - } else { - if (!leakWithinFunction) { - if (LOpts.getGC() == LangOptions::HybridGC) { - leakWithinFunction.reset(new Leak(this, - "Leak of object when not using " - "garbage collection (GC) in " - "dual GC/non-GC code")); - } else { - leakWithinFunction.reset(new Leak(this, "Leak")); - } - } - return leakWithinFunction.get(); - } + CFRefBug *getLeakWithinFunctionBug(const LangOptions &LOpts) const { + if (!leakWithinFunction) + leakWithinFunction.reset(new Leak(this, "Leak")); + return leakWithinFunction.get(); } - CFRefBug *getLeakAtReturnBug(const LangOptions &LOpts, bool GCEnabled) const { - if (GCEnabled) { - if (!leakAtReturnGC) - leakAtReturnGC.reset(new Leak(this, - "Leak of returned object when using " - "garbage collection")); - return leakAtReturnGC.get(); - } else { - if (!leakAtReturn) { - if (LOpts.getGC() == LangOptions::HybridGC) { - leakAtReturn.reset(new Leak(this, - "Leak of returned object when not using " - "garbage collection (GC) in dual " - "GC/non-GC code")); - } else { - leakAtReturn.reset(new Leak(this, "Leak of returned object")); - } - } + CFRefBug *getLeakAtReturnBug(const LangOptions &LOpts) const { + if (!leakAtReturn) + leakAtReturn.reset(new Leak(this, "Leak of returned object")); return leakAtReturn.get(); - } } - RetainSummaryManager &getSummaryManager(ASTContext &Ctx, - bool GCEnabled) const { + RetainSummaryManager &getSummaryManager(ASTContext &Ctx) const { // FIXME: We don't support ARC being turned on and off during one analysis. // (nor, for that matter, do we support changing ASTContexts) bool ARCEnabled = (bool)Ctx.getLangOpts().ObjCAutoRefCount; - if (GCEnabled) { - if (!SummariesGC) - SummariesGC.reset(new RetainSummaryManager(Ctx, true, ARCEnabled)); - else - assert(SummariesGC->isARCEnabled() == ARCEnabled); - return *SummariesGC; - } else { - if (!Summaries) - Summaries.reset(new RetainSummaryManager(Ctx, false, ARCEnabled)); - else - assert(Summaries->isARCEnabled() == ARCEnabled); - return *Summaries; - } + if (!Summaries) + Summaries.reset(new RetainSummaryManager(Ctx, ARCEnabled)); + else + assert(Summaries->isARCEnabled() == ARCEnabled); + return *Summaries; } RetainSummaryManager &getSummaryManager(CheckerContext &C) const { - return getSummaryManager(C.getASTContext(), C.isObjCGCEnabled()); + return getSummaryManager(C.getASTContext()); } void printState(raw_ostream &Out, ProgramStateRef State, @@ -3177,7 +2967,6 @@ break; } - case RetEffect::GCNotOwnedSymbol: case RetEffect::NotOwnedSymbol: { const Expr *Ex = CallOrMsg.getOriginExpr(); SymbolRef Sym = CallOrMsg.getReturnValue().getAsSymbol(); @@ -3217,12 +3006,7 @@ RetainCountChecker::updateSymbol(ProgramStateRef state, SymbolRef sym, RefVal V, ArgEffect E, RefVal::Kind &hasErr, CheckerContext &C) const { - // In GC mode [... release] and [... retain] do nothing. - // In ARC mode they shouldn't exist at all, but we just ignore them. - bool IgnoreRetainMsg = C.isObjCGCEnabled(); - if (!IgnoreRetainMsg) - IgnoreRetainMsg = (bool)C.getASTContext().getLangOpts().ObjCAutoRefCount; - + bool IgnoreRetainMsg = (bool)C.getASTContext().getLangOpts().ObjCAutoRefCount; switch (E) { default: break; @@ -3230,18 +3014,15 @@ E = IgnoreRetainMsg ? DoNothing : IncRef; break; case DecRefMsg: - E = IgnoreRetainMsg ? DoNothing : DecRef; + E = IgnoreRetainMsg ? DoNothing: DecRef; break; case DecRefMsgAndStopTrackingHard: E = IgnoreRetainMsg ? StopTracking : DecRefAndStopTrackingHard; break; - case MakeCollectable: - E = C.isObjCGCEnabled() ? DecRef : DoNothing; - break; } // Handle all use-after-releases. - if (!C.isObjCGCEnabled() && V.getKind() == RefVal::Released) { + if (V.getKind() == RefVal::Released) { V = V ^ RefVal::ErrorUseAfterRelease; hasErr = V.getKind(); return setRefBinding(state, sym, V); @@ -3250,9 +3031,8 @@ switch (E) { case DecRefMsg: case IncRefMsg: - case MakeCollectable: case DecRefMsgAndStopTrackingHard: - llvm_unreachable("DecRefMsg/IncRefMsg/MakeCollectable already converted"); + llvm_unreachable("DecRefMsg/IncRefMsg already converted"); case UnretainedOutParameter: case RetainedOutParameter: @@ -3260,13 +3040,6 @@ "not have ref state."); case Dealloc: - // Any use of -dealloc in GC is *bad*. - if (C.isObjCGCEnabled()) { - V = V ^ RefVal::ErrorDeallocGC; - hasErr = V.getKind(); - break; - } - switch (V.getKind()) { default: llvm_unreachable("Invalid RefVal state for an explicit dealloc."); @@ -3294,8 +3067,6 @@ return state; case Autorelease: - if (C.isObjCGCEnabled()) - return state; // Update the autorelease counts. V = V.autorelease(); break; @@ -3312,11 +3083,6 @@ case RefVal::NotOwned: V = V + 1; break; - case RefVal::Released: - // Non-GC cases are handled above. - assert(C.isObjCGCEnabled()); - V = (V ^ RefVal::Owned) + 1; - break; } break; @@ -3361,13 +3127,6 @@ hasErr = V.getKind(); } break; - - case RefVal::Released: - // Non-GC cases are handled above. - assert(C.isObjCGCEnabled()); - V = V ^ RefVal::ErrorUseAfterRelease; - hasErr = V.getKind(); - break; } break; } @@ -3407,11 +3166,6 @@ releaseNotOwned.reset(new BadRelease(this)); BT = releaseNotOwned.get(); break; - case RefVal::ErrorDeallocGC: - if (!deallocGC) - deallocGC.reset(new DeallocGC(this)); - BT = deallocGC.get(); - break; case RefVal::ErrorDeallocNotOwned: if (!deallocNotOwned) deallocNotOwned.reset(new DeallocNotOwned(this)); @@ -3421,7 +3175,7 @@ assert(BT); auto report = std::unique_ptr( - new CFRefReport(*BT, C.getASTContext().getLangOpts(), C.isObjCGCEnabled(), + new CFRefReport(*BT, C.getASTContext().getLangOpts(), SummaryLog, N, Sym)); report->addRange(ErrorRange); C.emitReport(std::move(report)); @@ -3443,7 +3197,7 @@ return false; // For now, we're only handling the functions that return aliases of their - // arguments: CFRetain and CFMakeCollectable (and their families). + // arguments: CFRetain (and its families). // Eventually we should add other functions we can model entirely, // such as CFRelease, which don't invalidate their arguments or globals. if (CE->getNumArgs() != 1) @@ -3460,19 +3214,14 @@ bool hasTrustedImplementationAnnotation = false; QualType ResultTy = CE->getCallReturnType(C.getASTContext()); - if (ResultTy->isObjCIdType()) { - // Handle: id NSMakeCollectable(CFTypeRef) - canEval = II->isStr("NSMakeCollectable"); - } else if (ResultTy->isPointerType()) { + if (ResultTy->isPointerType()) { // Handle: (CF|CG|CV)Retain // CFAutorelease - // CFMakeCollectable - // It's okay to be a little sloppy here (CGMakeCollectable doesn't exist). + // It's okay to be a little sloppy here. if (cocoa::isRefType(ResultTy, "CF", FName) || cocoa::isRefType(ResultTy, "CG", FName) || cocoa::isRefType(ResultTy, "CV", FName)) { - canEval = isRetain(FD, FName) || isAutorelease(FD, FName) || - isMakeCollectable(FD, FName); + canEval = isRetain(FD, FName) || isAutorelease(FD, FName); } else { if (FD->getDefinition()) { canEval = isTrustedReferenceCountImplementation(FD->getDefinition()); @@ -3641,18 +3390,9 @@ if (X.isReturnedOwned() && X.getCount() == 0) { if (RE.getKind() != RetEffect::NoRet) { bool hasError = false; - if (C.isObjCGCEnabled() && RE.getObjKind() == RetEffect::ObjC) { - // Things are more complicated with garbage collection. If the - // returned object is suppose to be an Objective-C object, we have - // a leak (as the caller expects a GC'ed object) because no - // method should return ownership unless it returns a CF object. - hasError = true; - X = X ^ RefVal::ErrorGCLeakReturned; - } - else if (!RE.isOwned()) { - // Either we are using GC and the returned object is a CF type - // or we aren't using GC. In either case, we expect that the - // enclosing method is expected to return ownership. + if (!RE.isOwned()) { + // The returning type is a CF, we expect the enclosing method should + // return ownership. hasError = true; X = X ^ RefVal::ErrorLeakReturned; } @@ -3665,9 +3405,8 @@ ExplodedNode *N = C.addTransition(state, Pred, &ReturnOwnLeakTag); if (N) { const LangOptions &LOpts = C.getASTContext().getLangOpts(); - bool GCEnabled = C.isObjCGCEnabled(); C.emitReport(std::unique_ptr(new CFRefLeakReport( - *getLeakAtReturnBug(LOpts, GCEnabled), LOpts, GCEnabled, + *getLeakAtReturnBug(LOpts), LOpts, SummaryLog, N, Sym, C, IncludeAllocationLine))); } } @@ -3695,7 +3434,7 @@ C.emitReport(std::unique_ptr(new CFRefReport( *returnNotOwnedForOwned, C.getASTContext().getLangOpts(), - C.isObjCGCEnabled(), SummaryLog, N, Sym))); + SummaryLog, N, Sym))); } } } @@ -3839,7 +3578,6 @@ if (!ACnt) return state; - assert(!Ctx.isObjCGCEnabled() && "Autorelease counts in GC mode?"); unsigned Cnt = V.getCount(); // FIXME: Handle sending 'autorelease' to already released object. @@ -3899,7 +3637,7 @@ const LangOptions &LOpts = Ctx.getASTContext().getLangOpts(); Ctx.emitReport(std::unique_ptr( - new CFRefReport(*overAutorelease, LOpts, /* GCEnabled = */ false, + new CFRefReport(*overAutorelease, LOpts, SummaryLog, N, Sym, os.str()))); } @@ -3947,13 +3685,12 @@ I = Leaked.begin(), E = Leaked.end(); I != E; ++I) { const LangOptions &LOpts = Ctx.getASTContext().getLangOpts(); - bool GCEnabled = Ctx.isObjCGCEnabled(); - CFRefBug *BT = Pred ? getLeakWithinFunctionBug(LOpts, GCEnabled) - : getLeakAtReturnBug(LOpts, GCEnabled); + CFRefBug *BT = Pred ? getLeakWithinFunctionBug(LOpts) + : getLeakAtReturnBug(LOpts); assert(BT && "BugType not initialized."); Ctx.emitReport(std::unique_ptr( - new CFRefLeakReport(*BT, LOpts, GCEnabled, SummaryLog, N, *I, Ctx, + new CFRefLeakReport(*BT, LOpts, SummaryLog, N, *I, Ctx, IncludeAllocationLine))); } } @@ -4130,7 +3867,7 @@ #define createCallEffect(D, KIND)\ ASTContext &Ctx = D->getASTContext();\ LangOptions L = Ctx.getLangOpts();\ - RetainSummaryManager M(Ctx, L.GCOnly, L.ObjCAutoRefCount);\ + RetainSummaryManager M(Ctx, L.ObjCAutoRefCount);\ const RetainSummary *S = M.get ## KIND ## Summary(D);\ CallEffects CE(S->getRetEffect());\ CE.Receiver = S->getReceiverEffect();\ Index: cfe/trunk/test/Analysis/CFDateGC.m =================================================================== --- cfe/trunk/test/Analysis/CFDateGC.m +++ cfe/trunk/test/Analysis/CFDateGC.m @@ -1,85 +0,0 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -fobjc-gc %s -Wno-implicit-function-declaration - -//===----------------------------------------------------------------------===// -// The following code is reduced using delta-debugging from -// Foundation.h and CoreFoundation.h (Mac OS X). -// -// It includes the basic definitions for the test cases below. -// Not directly including [Core]Foundation.h directly makes this test case -// both svelte and portable to non-Mac platforms. -//===----------------------------------------------------------------------===// - -typedef const void * CFTypeRef; -void CFRelease(CFTypeRef cf); -CFTypeRef CFRetain(CFTypeRef cf); -CFTypeRef CFMakeCollectable(CFTypeRef cf); -typedef const struct __CFAllocator * CFAllocatorRef; -typedef double CFTimeInterval; -typedef CFTimeInterval CFAbsoluteTime; -typedef const struct __CFDate * CFDateRef; -extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); -extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); -typedef struct objc_object {} *id; -typedef signed char BOOL; -static __inline__ __attribute__((always_inline)) id NSMakeCollectable(CFTypeRef cf) { return 0; } -@protocol NSObject - (BOOL)isEqual:(id)object; -- (oneway void)release; -- (id)retain; -@end -@class NSArray; - -//===----------------------------------------------------------------------===// -// Test cases. -//===----------------------------------------------------------------------===// - -CFAbsoluteTime CFAbsoluteTimeGetCurrent(); - -CFAbsoluteTime f1_use_after_release() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - CFRetain(date); - [NSMakeCollectable(date) release]; - CFDateGetAbsoluteTime(date); // no-warning - CFRelease(date); - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - -// The following two test cases verifies that CFMakeCollectable is a no-op -// in non-GC mode and a "release" in GC mode. -CFAbsoluteTime f2_use_after_release() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - CFRetain(date); - [(id) CFMakeCollectable(date) release]; - CFDateGetAbsoluteTime(date); // no-warning - CFRelease(date); - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - -CFAbsoluteTime f2_noleak() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - CFRetain(date); - [(id) CFMakeCollectable(date) release]; - CFDateGetAbsoluteTime(date); // no-warning - t = CFDateGetAbsoluteTime(date); // no-warning - CFRelease(date); // no-warning - return t; -} - -void f3_leak_with_gc() { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning 2 {{leak}} - [[(id) date retain] release]; -} - -// The following test case verifies that we "stop tracking" a retained object -// when it is passed as an argument to an implicitly defined function. -CFAbsoluteTime f4() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - CFRetain(date); - some_implicitly_defined_function_stop_tracking(date); // no-warning - return t; -} Index: cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes-gc.m.plist =================================================================== --- cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes-gc.m.plist +++ cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes-gc.m.plist @@ -1,1172 +0,0 @@ - diagnostics - - - path - - - kindevent - location - - line43 - col22 - file0 - - ranges - - - - line43 - col22 - file0 - - - line43 - col40 - file0 - - - - depth0 - extended_message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected - message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected - - - kindcontrol - edges - - - start - - - line43 - col3 - file0 - - - line43 - col11 - file0 - - - end - - - line44 - col3 - file0 - - - line44 - col8 - file0 - - - - - - - kindevent - location - - line44 - col3 - file0 - - ranges - - - - line44 - col3 - file0 - - - line44 - col8 - file0 - - - - depth0 - extended_message - Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 - message - Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 - - - descriptionPotential leak (when using garbage collection) of an object stored into 'leaked' - categoryMemory (Core Foundation/Objective-C) - typeLeak of object when using garbage collection - check_nameosx.cocoa.RetainCount - - issue_hash_content_of_line_in_context487197d1f3d333a1fb4d7610b6d852df - issue_context_kindfunction - issue_contextcreationViaCFCreate - issue_hash_function_offset1 - location - - line44 - col3 - file0 - - - - path - - - kindevent - location - - line48 - col22 - file0 - - ranges - - - - line48 - col22 - file0 - - - line48 - col40 - file0 - - - - depth0 - extended_message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected - message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected - - - kindcontrol - edges - - - start - - - line48 - col3 - file0 - - - line48 - col11 - file0 - - - end - - - line49 - col3 - file0 - - - line49 - col10 - file0 - - - - - - - kindevent - location - - line49 - col3 - file0 - - ranges - - - - line49 - col3 - file0 - - - line49 - col18 - file0 - - - - - line49 - col12 - file0 - - - line49 - col17 - file0 - - - - depth0 - extended_message - Reference count incremented. The object now has a +2 retain count - message - Reference count incremented. The object now has a +2 retain count - - - kindcontrol - edges - - - start - - - line49 - col3 - file0 - - - line49 - col10 - file0 - - - end - - - line50 - col3 - file0 - - - line50 - col19 - file0 - - - - - - - kindevent - location - - line50 - col3 - file0 - - ranges - - - - line50 - col3 - file0 - - - line50 - col27 - file0 - - - - - line50 - col21 - file0 - - - line50 - col26 - file0 - - - - depth0 - extended_message - In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1 - message - In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1 - - - kindcontrol - edges - - - start - - - line50 - col3 - file0 - - - line50 - col19 - file0 - - - end - - - line51 - col3 - file0 - - - line51 - col19 - file0 - - - - - - - kindevent - location - - line51 - col3 - file0 - - ranges - - - - line51 - col3 - file0 - - - line51 - col27 - file0 - - - - - line51 - col21 - file0 - - - line51 - col26 - file0 - - - - depth0 - extended_message - In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector - message - In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector - - - kindcontrol - edges - - - start - - - line51 - col3 - file0 - - - line51 - col19 - file0 - - - end - - - line52 - col3 - file0 - - - line52 - col10 - file0 - - - - - - - kindevent - location - - line52 - col3 - file0 - - ranges - - - - line52 - col3 - file0 - - - line52 - col18 - file0 - - - - - line52 - col12 - file0 - - - line52 - col17 - file0 - - - - depth0 - extended_message - Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again - message - Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again - - - kindcontrol - edges - - - start - - - line52 - col3 - file0 - - - line52 - col10 - file0 - - - end - - - line53 - col3 - file0 - - - line53 - col8 - file0 - - - - - - - kindevent - location - - line53 - col3 - file0 - - ranges - - - - line53 - col3 - file0 - - - line53 - col8 - file0 - - - - depth0 - extended_message - Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 - message - Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 - - - descriptionPotential leak (when using garbage collection) of an object stored into 'leaked' - categoryMemory (Core Foundation/Objective-C) - typeLeak of object when using garbage collection - check_nameosx.cocoa.RetainCount - - issue_hash_content_of_line_in_context4f71073d5e7f2546564c1614dfc95420 - issue_context_kindfunction - issue_contextmakeCollectable - issue_hash_function_offset1 - location - - line53 - col3 - file0 - - - - path - - - kindevent - location - - line57 - col15 - file0 - - ranges - - - - line57 - col15 - file0 - - - line57 - col37 - file0 - - - - depth0 - extended_message - Method returns an instance of NSObject with a +0 retain count - message - Method returns an instance of NSObject with a +0 retain count - - - kindcontrol - edges - - - start - - - line57 - col3 - file0 - - - line57 - col4 - file0 - - - end - - - line58 - col3 - file0 - - - line58 - col3 - file0 - - - - - - - kindevent - location - - line58 - col3 - file0 - - ranges - - - - line58 - col3 - file0 - - - line58 - col17 - file0 - - - - - line58 - col4 - file0 - - - line58 - col9 - file0 - - - - depth0 - extended_message - In GC mode the 'retain' message has no effect - message - In GC mode the 'retain' message has no effect - - - kindcontrol - edges - - - start - - - line58 - col3 - file0 - - - line58 - col3 - file0 - - - end - - - line59 - col3 - file0 - - - line59 - col3 - file0 - - - - - - - kindevent - location - - line59 - col3 - file0 - - ranges - - - - line59 - col3 - file0 - - - line59 - col18 - file0 - - - - - line59 - col4 - file0 - - - line59 - col9 - file0 - - - - depth0 - extended_message - In GC mode the 'release' message has no effect - message - In GC mode the 'release' message has no effect - - - kindcontrol - edges - - - start - - - line59 - col3 - file0 - - - line59 - col3 - file0 - - - end - - - line60 - col3 - file0 - - - line60 - col3 - file0 - - - - - - - kindevent - location - - line60 - col3 - file0 - - ranges - - - - line60 - col3 - file0 - - - line60 - col22 - file0 - - - - - line60 - col4 - file0 - - - line60 - col9 - file0 - - - - depth0 - extended_message - In GC mode an 'autorelease' has no effect - message - In GC mode an 'autorelease' has no effect - - - kindcontrol - edges - - - start - - - line60 - col3 - file0 - - - line60 - col3 - file0 - - - end - - - line61 - col3 - file0 - - - line61 - col11 - file0 - - - - - - - kindevent - location - - line61 - col3 - file0 - - ranges - - - - line61 - col13 - file0 - - - line61 - col29 - file0 - - - - depth0 - extended_message - Incorrect decrement of the reference count of an object that is not owned at this point by the caller - message - Incorrect decrement of the reference count of an object that is not owned at this point by the caller - - - descriptionIncorrect decrement of the reference count of an object that is not owned at this point by the caller - categoryMemory (Core Foundation/Objective-C) - typeBad release - check_nameosx.cocoa.RetainCount - - issue_hash_content_of_line_in_context3d18c66bf99e8cd2938e8c63c345f6ea - issue_context_kindfunction - issue_contextretainReleaseIgnored - issue_hash_function_offset5 - location - - line61 - col3 - file0 - - - - path - - - kindevent - location - - line66 - col20 - file0 - - ranges - - - - line66 - col20 - file0 - - - line66 - col38 - file0 - - - - depth0 - extended_message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected - message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected - - - kindcontrol - edges - - - start - - - line66 - col3 - file0 - - - line66 - col4 - file0 - - - end - - - line67 - col3 - file0 - - - line67 - col8 - file0 - - - - - - - kindevent - location - - line67 - col3 - file0 - - ranges - - - - line67 - col3 - file0 - - - line67 - col15 - file0 - - - - - line67 - col10 - file0 - - - line67 - col15 - file0 - - - - depth0 - extended_message - Object returned to caller as an owning reference (single retain count transferred to caller) - message - Object returned to caller as an owning reference (single retain count transferred to caller) - - - kindevent - location - - line67 - col3 - file0 - - ranges - - - - line67 - col3 - file0 - - - line67 - col15 - file0 - - - - depth0 - extended_message - Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector - message - Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector - - - descriptionPotential leak (when using garbage collection) of an object stored into 'object' - categoryMemory (Core Foundation/Objective-C) - typeLeak of returned object when using garbage collection - check_nameosx.cocoa.RetainCount - - issue_hash_content_of_line_in_contextd012b4dfd7d763f06cdb53f8b5708275 - issue_context_kindObjective-C method - issue_contextgetViolation - issue_hash_function_offset1 - location - - line67 - col3 - file0 - - - - path - - - kindevent - location - - line71 - col20 - file0 - - ranges - - - - line71 - col20 - file0 - - - line71 - col38 - file0 - - - - depth0 - extended_message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected - message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected - - - kindcontrol - edges - - - start - - - line71 - col3 - file0 - - - line71 - col4 - file0 - - - end - - - line72 - col3 - file0 - - - line72 - col8 - file0 - - - - - - - kindevent - location - - line72 - col3 - file0 - - ranges - - - - line72 - col3 - file0 - - - line72 - col15 - file0 - - - - - line72 - col10 - file0 - - - line72 - col15 - file0 - - - - depth0 - extended_message - Object returned to caller as an owning reference (single retain count transferred to caller) - message - Object returned to caller as an owning reference (single retain count transferred to caller) - - - kindevent - location - - line72 - col3 - file0 - - ranges - - - - line72 - col3 - file0 - - - line72 - col15 - file0 - - - - depth0 - extended_message - Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector - message - Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector - - - descriptionPotential leak (when using garbage collection) of an object stored into 'object' - categoryMemory (Core Foundation/Objective-C) - typeLeak of returned object when using garbage collection - check_nameosx.cocoa.RetainCount - - issue_hash_content_of_line_in_contextb241509266f9d666b8335e0ee2f45adf - issue_context_kindObjective-C method - issue_contextcopyViolation - issue_hash_function_offset1 - location - - line72 - col3 - file0 - - - - - Index: cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist =================================================================== --- cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist +++ cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist @@ -7,7 +7,7 @@ kindevent location - line47 + line44 col15 file0 @@ -15,12 +15,12 @@ - line47 + line44 col15 file0 - line47 + line44 col37 file0 @@ -40,12 +40,12 @@ start - line47 + line44 col3 file0 - line47 + line44 col4 file0 @@ -53,12 +53,12 @@ end - line48 + line45 col3 file0 - line48 + line45 col8 file0 @@ -70,7 +70,7 @@ kindevent location - line48 + line45 col3 file0 @@ -78,12 +78,12 @@ - line48 + line45 col3 file0 - line48 + line45 col8 file0 @@ -107,7 +107,7 @@ issue_hash_function_offset1 location - line48 + line45 col3 file0 @@ -119,7 +119,7 @@ kindevent location - line52 + line49 col22 file0 @@ -127,12 +127,12 @@ - line52 + line49 col22 file0 - line52 + line49 col40 file0 @@ -152,12 +152,12 @@ start - line52 + line49 col3 file0 - line52 + line49 col11 file0 @@ -165,12 +165,12 @@ end - line53 + line50 col3 file0 - line53 + line50 col8 file0 @@ -182,7 +182,7 @@ kindevent location - line53 + line50 col3 file0 @@ -190,12 +190,12 @@ - line53 + line50 col3 file0 - line53 + line50 col8 file0 @@ -219,7 +219,7 @@ issue_hash_function_offset1 location - line53 + line50 col3 file0 @@ -231,7 +231,7 @@ kindevent location - line57 + line54 col15 file0 @@ -239,12 +239,12 @@ - line57 + line54 col15 file0 - line57 + line54 col35 file0 @@ -264,12 +264,12 @@ start - line57 + line54 col3 file0 - line57 + line54 col4 file0 @@ -277,12 +277,12 @@ end - line58 + line55 col3 file0 - line58 + line55 col3 file0 @@ -294,7 +294,7 @@ kindevent location - line58 + line55 col3 file0 @@ -302,24 +302,24 @@ - line58 + line55 col3 file0 - line58 + line55 col17 file0 - line58 + line55 col4 file0 - line58 + line55 col9 file0 @@ -339,12 +339,12 @@ start - line58 + line55 col3 file0 - line58 + line55 col3 file0 @@ -352,12 +352,12 @@ end - line59 + line56 col3 file0 - line59 + line56 col3 file0 @@ -369,7 +369,7 @@ kindevent location - line59 + line56 col3 file0 @@ -377,24 +377,24 @@ - line59 + line56 col3 file0 - line59 + line56 col17 file0 - line59 + line56 col4 file0 - line59 + line56 col9 file0 @@ -414,12 +414,12 @@ start - line59 + line56 col3 file0 - line59 + line56 col3 file0 @@ -427,12 +427,12 @@ end - line60 + line57 col3 file0 - line60 + line57 col3 file0 @@ -444,7 +444,7 @@ kindevent location - line60 + line57 col3 file0 @@ -452,24 +452,24 @@ - line60 + line57 col3 file0 - line60 + line57 col18 file0 - line60 + line57 col4 file0 - line60 + line57 col9 file0 @@ -489,12 +489,12 @@ start - line60 + line57 col3 file0 - line60 + line57 col3 file0 @@ -502,12 +502,12 @@ end - line61 + line58 col3 file0 - line61 + line58 col8 file0 @@ -519,7 +519,7 @@ kindevent location - line61 + line58 col3 file0 @@ -527,12 +527,12 @@ - line61 + line58 col3 file0 - line61 + line58 col8 file0 @@ -556,7 +556,7 @@ issue_hash_function_offset1 location - line61 + line58 col3 file0 @@ -568,7 +568,7 @@ kindevent location - line65 + line62 col19 file0 @@ -576,12 +576,12 @@ - line65 + line62 col19 file0 - line65 + line62 col31 file0 @@ -601,12 +601,12 @@ start - line65 + line62 col3 file0 - line65 + line62 col4 file0 @@ -614,12 +614,12 @@ end - line66 + line63 col3 file0 - line66 + line63 col3 file0 @@ -631,7 +631,7 @@ kindevent location - line66 + line63 col3 file0 @@ -639,24 +639,24 @@ - line66 + line63 col3 file0 - line66 + line63 col17 file0 - line66 + line63 col4 file0 - line66 + line63 col9 file0 @@ -676,12 +676,12 @@ start - line66 + line63 col3 file0 - line66 + line63 col3 file0 @@ -689,12 +689,12 @@ end - line67 + line64 col3 file0 - line67 + line64 col8 file0 @@ -706,7 +706,7 @@ kindevent location - line67 + line64 col3 file0 @@ -714,12 +714,12 @@ - line67 + line64 col3 file0 - line67 + line64 col8 file0 @@ -743,7 +743,7 @@ issue_hash_function_offset1 location - line67 + line64 col3 file0 @@ -755,7 +755,7 @@ kindevent location - line71 + line68 col22 file0 @@ -763,12 +763,12 @@ - line71 + line68 col22 file0 - line71 + line68 col37 file0 @@ -788,12 +788,12 @@ start - line71 + line68 col3 file0 - line71 + line68 col11 file0 @@ -801,12 +801,12 @@ end - line72 + line69 col3 file0 - line72 + line69 col10 file0 @@ -818,7 +818,7 @@ kindevent location - line72 + line69 col3 file0 @@ -826,24 +826,24 @@ - line72 + line69 col3 file0 - line72 + line69 col18 file0 - line72 + line69 col12 file0 - line72 + line69 col17 file0 @@ -863,12 +863,12 @@ start - line72 + line69 col3 file0 - line72 + line69 col10 file0 @@ -876,12 +876,12 @@ end - line73 + line70 col3 file0 - line73 + line70 col8 file0 @@ -893,7 +893,7 @@ kindevent location - line73 + line70 col3 file0 @@ -901,12 +901,12 @@ - line73 + line70 col3 file0 - line73 + line70 col8 file0 @@ -930,7 +930,7 @@ issue_hash_function_offset1 location - line73 + line70 col3 file0 @@ -942,7 +942,7 @@ kindevent location - line77 + line74 col15 file0 @@ -950,12 +950,12 @@ - line77 + line74 col15 file0 - line77 + line74 col37 file0 @@ -975,12 +975,12 @@ start - line77 + line74 col3 file0 - line77 + line74 col4 file0 @@ -988,12 +988,12 @@ end - line78 + line75 col3 file0 - line78 + line75 col3 file0 @@ -1005,7 +1005,7 @@ kindevent location - line78 + line75 col3 file0 @@ -1013,24 +1013,24 @@ - line78 + line75 col3 file0 - line78 + line75 col18 file0 - line78 + line75 col4 file0 - line78 + line75 col9 file0 @@ -1050,12 +1050,12 @@ start - line78 + line75 col3 file0 - line78 + line75 col3 file0 @@ -1063,12 +1063,12 @@ end - line79 + line76 col3 file0 - line79 + line76 col3 file0 @@ -1080,7 +1080,7 @@ kindevent location - line79 + line76 col3 file0 @@ -1088,12 +1088,12 @@ - line79 + line76 col4 file0 - line79 + line76 col9 file0 @@ -1117,7 +1117,7 @@ issue_hash_function_offset3 location - line79 + line76 col3 file0 @@ -1129,7 +1129,7 @@ kindevent location - line83 + line80 col15 file0 @@ -1137,12 +1137,12 @@ - line83 + line80 col15 file0 - line83 + line80 col37 file0 @@ -1162,12 +1162,12 @@ start - line83 + line80 col3 file0 - line83 + line80 col4 file0 @@ -1175,12 +1175,12 @@ end - line84 + line81 col3 file0 - line84 + line81 col3 file0 @@ -1192,7 +1192,7 @@ kindevent location - line84 + line81 col3 file0 @@ -1200,24 +1200,24 @@ - line84 + line81 col3 file0 - line84 + line81 col18 file0 - line84 + line81 col4 file0 - line84 + line81 col9 file0 @@ -1237,12 +1237,12 @@ start - line84 + line81 col3 file0 - line84 + line81 col3 file0 @@ -1250,12 +1250,12 @@ end - line85 + line82 col3 file0 - line85 + line82 col3 file0 @@ -1267,7 +1267,7 @@ kindevent location - line85 + line82 col3 file0 @@ -1275,12 +1275,12 @@ - line85 + line82 col4 file0 - line85 + line82 col9 file0 @@ -1304,7 +1304,7 @@ issue_hash_function_offset3 location - line85 + line82 col3 file0 @@ -1316,7 +1316,7 @@ kindevent location - line89 + line86 col15 file0 @@ -1324,12 +1324,12 @@ - line89 + line86 col15 file0 - line89 + line86 col37 file0 @@ -1349,12 +1349,12 @@ start - line89 + line86 col3 file0 - line89 + line86 col4 file0 @@ -1362,12 +1362,12 @@ end - line90 + line87 col3 file0 - line90 + line87 col3 file0 @@ -1379,7 +1379,7 @@ kindevent location - line90 + line87 col3 file0 @@ -1387,24 +1387,24 @@ - line90 + line87 col3 file0 - line90 + line87 col22 file0 - line90 + line87 col4 file0 - line90 + line87 col9 file0 @@ -1424,12 +1424,12 @@ start - line90 + line87 col3 file0 - line90 + line87 col3 file0 @@ -1437,12 +1437,12 @@ end - line91 + line88 col3 file0 - line91 + line88 col3 file0 @@ -1454,7 +1454,7 @@ kindevent location - line91 + line88 col3 file0 @@ -1462,24 +1462,24 @@ - line91 + line88 col3 file0 - line91 + line88 col22 file0 - line91 + line88 col4 file0 - line91 + line88 col9 file0 @@ -1499,12 +1499,12 @@ start - line91 + line88 col3 file0 - line91 + line88 col3 file0 @@ -1512,12 +1512,12 @@ end - line92 + line89 col3 file0 - line92 + line89 col8 file0 @@ -1529,7 +1529,7 @@ kindevent location - line92 + line89 col3 file0 @@ -1537,12 +1537,12 @@ - line92 + line89 col3 file0 - line92 + line89 col8 file0 @@ -1566,7 +1566,7 @@ issue_hash_function_offset4 location - line92 + line89 col3 file0 @@ -1578,7 +1578,7 @@ kindevent location - line96 + line93 col19 file0 @@ -1586,12 +1586,12 @@ - line96 + line93 col19 file0 - line96 + line93 col31 file0 @@ -1611,12 +1611,12 @@ start - line96 + line93 col3 file0 - line96 + line93 col4 file0 @@ -1624,12 +1624,12 @@ end - line97 + line94 col3 file0 - line97 + line94 col3 file0 @@ -1641,7 +1641,7 @@ kindevent location - line97 + line94 col3 file0 @@ -1649,24 +1649,24 @@ - line97 + line94 col3 file0 - line97 + line94 col22 file0 - line97 + line94 col4 file0 - line97 + line94 col9 file0 @@ -1686,12 +1686,12 @@ start - line97 + line94 col3 file0 - line97 + line94 col3 file0 @@ -1699,12 +1699,12 @@ end - line98 + line95 col3 file0 - line98 + line95 col8 file0 @@ -1716,7 +1716,7 @@ kindevent location - line98 + line95 col3 file0 @@ -1724,12 +1724,12 @@ - line98 + line95 col3 file0 - line98 + line95 col8 file0 @@ -1739,283 +1739,21 @@ extended_message Object was autoreleased but has a +0 retain count message - Object was autoreleased but has a +0 retain count - - - descriptionObject autoreleased too many times - categoryMemory (Core Foundation/Objective-C) - typeObject autoreleased too many times - check_nameosx.cocoa.RetainCount - - issue_hash_content_of_line_in_context1edd178e5ad76c79ce9812f519e8f467 - issue_context_kindfunction - issue_contextautoreleaseUnowned - issue_hash_function_offset3 - location - - line98 - col3 - file0 - - - - path - - - kindevent - location - - line102 - col22 - file0 - - ranges - - - - line102 - col22 - file0 - - - line102 - col40 - file0 - - - - depth0 - extended_message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count - message - Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count - - - kindcontrol - edges - - - start - - - line102 - col3 - file0 - - - line102 - col11 - file0 - - - end - - - line103 - col3 - file0 - - - line103 - col19 - file0 - - - - - - - kindevent - location - - line103 - col3 - file0 - - ranges - - - - line103 - col3 - file0 - - - line103 - col27 - file0 - - - - - line103 - col21 - file0 - - - line103 - col26 - file0 - - - - depth0 - extended_message - When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument - message - When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument - - - kindcontrol - edges - - - start - - - line103 - col3 - file0 - - - line103 - col19 - file0 - - - end - - - line104 - col3 - file0 - - - line104 - col19 - file0 - - - - - - - kindevent - location - - line104 - col3 - file0 - - ranges - - - - line104 - col3 - file0 - - - line104 - col27 - file0 - - - - - line104 - col21 - file0 - - - line104 - col26 - file0 - - - - depth0 - extended_message - When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument - message - When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument - - - kindcontrol - edges - - - start - - - line104 - col3 - file0 - - - line104 - col19 - file0 - - - end - - - line105 - col3 - file0 - - - line105 - col8 - file0 - - - - - - - kindevent - location - - line105 - col3 - file0 - - ranges - - - - line105 - col3 - file0 - - - line105 - col8 - file0 - - - - depth0 - extended_message - Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 - message - Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1 + Object was autoreleased but has a +0 retain count - descriptionPotential leak of an object stored into 'leaked' + descriptionObject autoreleased too many times categoryMemory (Core Foundation/Objective-C) - typeLeak + typeObject autoreleased too many times check_nameosx.cocoa.RetainCount - issue_hash_content_of_line_in_context3f08690fae9687c29bb23b7a7cb7995b + issue_hash_content_of_line_in_context1edd178e5ad76c79ce9812f519e8f467 issue_context_kindfunction - issue_contextmakeCollectableIgnored - issue_hash_function_offset1 + issue_contextautoreleaseUnowned + issue_hash_function_offset3 location - line105 + line95 col3 file0 @@ -2027,7 +1765,7 @@ kindevent location - line109 + line99 col22 file0 @@ -2035,12 +1773,12 @@ - line109 + line99 col22 file0 - line109 + line99 col37 file0 @@ -2060,12 +1798,12 @@ start - line109 + line99 col3 file0 - line109 + line99 col11 file0 @@ -2073,12 +1811,12 @@ end - line110 + line100 col3 file0 - line110 + line100 col8 file0 @@ -2090,7 +1828,7 @@ kindevent location - line110 + line100 col3 file0 @@ -2098,24 +1836,24 @@ - line110 + line100 col3 file0 - line110 + line100 col15 file0 - line110 + line100 col10 file0 - line110 + line100 col15 file0 @@ -2131,7 +1869,7 @@ kindevent location - line110 + line100 col3 file0 @@ -2139,12 +1877,12 @@ - line110 + line100 col3 file0 - line110 + line100 col15 file0 @@ -2168,7 +1906,7 @@ issue_hash_function_offset2 location - line110 + line100 col3 file0 @@ -2180,7 +1918,7 @@ kindevent location - line114 + line104 col22 file0 @@ -2188,12 +1926,12 @@ - line114 + line104 col22 file0 - line114 + line104 col40 file0 @@ -2213,12 +1951,12 @@ start - line114 + line104 col3 file0 - line114 + line104 col11 file0 @@ -2226,12 +1964,12 @@ end - line115 + line105 col3 file0 - line115 + line105 col8 file0 @@ -2243,7 +1981,7 @@ kindevent location - line115 + line105 col3 file0 @@ -2251,24 +1989,24 @@ - line115 + line105 col3 file0 - line115 + line105 col15 file0 - line115 + line105 col10 file0 - line115 + line105 col15 file0 @@ -2284,7 +2022,7 @@ kindevent location - line115 + line105 col3 file0 @@ -2292,12 +2030,12 @@ - line115 + line105 col3 file0 - line115 + line105 col15 file0 @@ -2321,7 +2059,7 @@ issue_hash_function_offset1 location - line115 + line105 col3 file0 @@ -2333,7 +2071,7 @@ kindevent location - line120 + line110 col20 file0 @@ -2341,12 +2079,12 @@ - line120 + line110 col20 file0 - line120 + line110 col32 file0 @@ -2366,12 +2104,12 @@ start - line120 + line110 col3 file0 - line120 + line110 col4 file0 @@ -2379,12 +2117,12 @@ end - line121 + line111 col3 file0 - line121 + line111 col8 file0 @@ -2396,7 +2134,7 @@ kindevent location - line121 + line111 col3 file0 @@ -2404,24 +2142,24 @@ - line121 + line111 col3 file0 - line121 + line111 col15 file0 - line121 + line111 col10 file0 - line121 + line111 col15 file0 @@ -2437,7 +2175,7 @@ kindevent location - line121 + line111 col3 file0 @@ -2445,12 +2183,12 @@ - line121 + line111 col3 file0 - line121 + line111 col15 file0 @@ -2474,7 +2212,7 @@ issue_hash_function_offset2 location - line121 + line111 col3 file0 @@ -2486,7 +2224,7 @@ kindevent location - line125 + line115 col15 file0 @@ -2494,12 +2232,12 @@ - line125 + line115 col15 file0 - line125 + line115 col18 file0 @@ -2519,12 +2257,12 @@ start - line125 + line115 col3 file0 - line125 + line115 col4 file0 @@ -2532,12 +2270,12 @@ end - line126 + line116 col3 file0 - line126 + line116 col8 file0 @@ -2549,7 +2287,7 @@ kindevent location - line126 + line116 col3 file0 @@ -2557,24 +2295,24 @@ - line126 + line116 col3 file0 - line126 + line116 col15 file0 - line126 + line116 col10 file0 - line126 + line116 col15 file0 @@ -2590,7 +2328,7 @@ kindevent location - line126 + line116 col3 file0 @@ -2598,12 +2336,12 @@ - line126 + line116 col3 file0 - line126 + line116 col15 file0 @@ -2627,7 +2365,7 @@ issue_hash_function_offset2 location - line126 + line116 col3 file0 @@ -2639,7 +2377,7 @@ kindevent location - line130 + line120 col15 file0 @@ -2647,12 +2385,12 @@ - line130 + line120 col15 file0 - line130 + line120 col18 file0 @@ -2672,12 +2410,12 @@ start - line130 + line120 col3 file0 - line130 + line120 col4 file0 @@ -2685,12 +2423,12 @@ end - line131 + line121 col3 file0 - line131 + line121 col8 file0 @@ -2702,7 +2440,7 @@ kindevent location - line131 + line121 col3 file0 @@ -2710,24 +2448,24 @@ - line131 + line121 col3 file0 - line131 + line121 col15 file0 - line131 + line121 col10 file0 - line131 + line121 col15 file0 @@ -2743,7 +2481,7 @@ kindevent location - line131 + line121 col3 file0 @@ -2751,12 +2489,12 @@ - line131 + line121 col3 file0 - line131 + line121 col15 file0 @@ -2780,7 +2518,7 @@ issue_hash_function_offset2 location - line131 + line121 col3 file0 @@ -2792,7 +2530,7 @@ kindevent location - line135 + line125 col15 file0 @@ -2800,12 +2538,12 @@ - line135 + line125 col15 file0 - line135 + line125 col32 file0 @@ -2825,12 +2563,12 @@ start - line135 + line125 col3 file0 - line135 + line125 col4 file0 @@ -2838,12 +2576,12 @@ end - line136 + line126 col3 file0 - line136 + line126 col8 file0 @@ -2855,7 +2593,7 @@ kindevent location - line136 + line126 col3 file0 @@ -2863,24 +2601,24 @@ - line136 + line126 col3 file0 - line136 + line126 col15 file0 - line136 + line126 col10 file0 - line136 + line126 col15 file0 @@ -2896,7 +2634,7 @@ kindevent location - line136 + line126 col3 file0 @@ -2904,12 +2642,12 @@ - line136 + line126 col3 file0 - line136 + line126 col15 file0 @@ -2933,7 +2671,7 @@ issue_hash_function_offset1 location - line136 + line126 col3 file0 @@ -2945,7 +2683,7 @@ kindevent location - line140 + line130 col15 file0 @@ -2953,12 +2691,12 @@ - line140 + line130 col15 file0 - line140 + line130 col32 file0 @@ -2978,12 +2716,12 @@ start - line140 + line130 col3 file0 - line140 + line130 col4 file0 @@ -2991,12 +2729,12 @@ end - line141 + line131 col3 file0 - line141 + line131 col3 file0 @@ -3008,7 +2746,7 @@ kindevent location - line141 + line131 col3 file0 @@ -3016,24 +2754,24 @@ - line141 + line131 col3 file0 - line141 + line131 col22 file0 - line141 + line131 col4 file0 - line141 + line131 col9 file0 @@ -3053,12 +2791,12 @@ start - line141 + line131 col3 file0 - line141 + line131 col3 file0 @@ -3066,12 +2804,12 @@ end - line142 + line132 col3 file0 - line142 + line132 col8 file0 @@ -3083,7 +2821,7 @@ kindevent location - line142 + line132 col3 file0 @@ -3091,12 +2829,12 @@ - line142 + line132 col3 file0 - line142 + line132 col15 file0 @@ -3120,7 +2858,7 @@ issue_hash_function_offset3 location - line142 + line132 col3 file0 @@ -3132,7 +2870,7 @@ kindevent location - line170 + line160 col15 file0 @@ -3140,12 +2878,12 @@ - line170 + line160 col15 file0 - line170 + line160 col16 file0 @@ -3165,12 +2903,12 @@ start - line170 + line160 col3 file0 - line170 + line160 col4 file0 @@ -3178,12 +2916,12 @@ end - line171 + line161 col3 file0 - line171 + line161 col3 file0 @@ -3195,7 +2933,7 @@ kindevent location - line171 + line161 col3 file0 @@ -3203,12 +2941,12 @@ - line171 + line161 col4 file0 - line171 + line161 col9 file0 @@ -3232,7 +2970,7 @@ issue_hash_function_offset2 location - line171 + line161 col3 file0 @@ -3244,7 +2982,7 @@ kindevent location - line175 + line165 col15 file0 @@ -3252,12 +2990,12 @@ - line175 + line165 col15 file0 - line175 + line165 col18 file0 @@ -3277,12 +3015,12 @@ start - line175 + line165 col3 file0 - line175 + line165 col4 file0 @@ -3290,12 +3028,12 @@ end - line176 + line166 col3 file0 - line176 + line166 col3 file0 @@ -3307,7 +3045,7 @@ kindevent location - line176 + line166 col3 file0 @@ -3315,12 +3053,12 @@ - line176 + line166 col4 file0 - line176 + line166 col9 file0 @@ -3344,7 +3082,7 @@ issue_hash_function_offset2 location - line176 + line166 col3 file0 @@ -3356,7 +3094,7 @@ kindevent location - line180 + line170 col15 file0 @@ -3364,12 +3102,12 @@ - line180 + line170 col15 file0 - line180 + line170 col20 file0 @@ -3389,12 +3127,12 @@ start - line180 + line170 col3 file0 - line180 + line170 col4 file0 @@ -3402,12 +3140,12 @@ end - line181 + line171 col3 file0 - line181 + line171 col3 file0 @@ -3419,7 +3157,7 @@ kindevent location - line181 + line171 col3 file0 @@ -3427,12 +3165,12 @@ - line181 + line171 col4 file0 - line181 + line171 col9 file0 @@ -3456,7 +3194,7 @@ issue_hash_function_offset2 location - line181 + line171 col3 file0 @@ -3468,7 +3206,7 @@ kindevent location - line185 + line175 col15 file0 @@ -3476,12 +3214,12 @@ - line185 + line175 col15 file0 - line185 + line175 col20 file0 @@ -3501,12 +3239,12 @@ start - line185 + line175 col3 file0 - line185 + line175 col4 file0 @@ -3514,12 +3252,12 @@ end - line186 + line176 col3 file0 - line186 + line176 col3 file0 @@ -3531,7 +3269,7 @@ kindevent location - line186 + line176 col3 file0 @@ -3539,12 +3277,12 @@ - line186 + line176 col4 file0 - line186 + line176 col9 file0 @@ -3568,7 +3306,7 @@ issue_hash_function_offset2 location - line186 + line176 col3 file0 @@ -3580,7 +3318,7 @@ kindevent location - line190 + line180 col15 file0 @@ -3588,12 +3326,12 @@ - line190 + line180 col15 file0 - line190 + line180 col27 file0 @@ -3613,12 +3351,12 @@ start - line190 + line180 col3 file0 - line190 + line180 col4 file0 @@ -3626,12 +3364,12 @@ end - line191 + line181 col3 file0 - line191 + line181 col3 file0 @@ -3643,7 +3381,7 @@ kindevent location - line191 + line181 col3 file0 @@ -3651,12 +3389,12 @@ - line191 + line181 col4 file0 - line191 + line181 col9 file0 @@ -3680,7 +3418,7 @@ issue_hash_function_offset2 location - line191 + line181 col3 file0 @@ -3696,12 +3434,12 @@ start - line226 + line216 col3 file0 - line226 + line216 col4 file0 @@ -3709,12 +3447,12 @@ end - line226 + line216 col11 file0 - line226 + line216 col11 file0 @@ -3726,7 +3464,7 @@ kindevent location - line226 + line216 col11 file0 @@ -3734,12 +3472,12 @@ - line226 + line216 col11 file0 - line226 + line216 col23 file0 @@ -3755,7 +3493,7 @@ kindevent location - line226 + line216 col10 file0 @@ -3763,12 +3501,12 @@ - line226 + line216 col10 file0 - line226 + line216 col30 file0 @@ -3784,7 +3522,7 @@ kindevent location - line206 + line196 col1 file0 @@ -3802,12 +3540,12 @@ start - line206 + line196 col1 file0 - line206 + line196 col1 file0 @@ -3815,12 +3553,12 @@ end - line207 + line197 col3 file0 - line207 + line197 col4 file0 @@ -3836,12 +3574,12 @@ start - line207 + line197 col3 file0 - line207 + line197 col4 file0 @@ -3849,12 +3587,12 @@ end - line207 + line197 col7 file0 - line207 + line197 col10 file0 @@ -3866,7 +3604,7 @@ kindevent location - line207 + line197 col7 file0 @@ -3874,12 +3612,12 @@ - line207 + line197 col7 file0 - line207 + line197 col10 file0 @@ -3899,12 +3637,12 @@ start - line207 + line197 col7 file0 - line207 + line197 col10 file0 @@ -3912,12 +3650,12 @@ end - line209 + line199 col5 file0 - line209 + line199 col10 file0 @@ -3929,7 +3667,7 @@ kindevent location - line226 + line216 col10 file0 @@ -3937,12 +3675,12 @@ - line226 + line216 col10 file0 - line226 + line216 col30 file0 @@ -3962,12 +3700,12 @@ start - line226 + line216 col10 file0 - line226 + line216 col10 file0 @@ -3975,12 +3713,12 @@ end - line226 + line216 col3 file0 - line226 + line216 col4 file0 @@ -3992,7 +3730,7 @@ kindevent location - line226 + line216 col3 file0 @@ -4000,12 +3738,12 @@ - line226 + line216 col3 file0 - line226 + line216 col6 file0 @@ -4029,7 +3767,7 @@ issue_hash_function_offset2 location - line226 + line216 col3 file0 @@ -4045,12 +3783,12 @@ start - line226 + line216 col3 file0 - line226 + line216 col4 file0 @@ -4058,12 +3796,12 @@ end - line232 + line222 col3 file0 - line232 + line222 col4 file0 @@ -4079,12 +3817,12 @@ start - line232 + line222 col3 file0 - line232 + line222 col4 file0 @@ -4092,12 +3830,12 @@ end - line232 + line222 col10 file0 - line232 + line222 col10 file0 @@ -4109,7 +3847,7 @@ kindevent location - line232 + line222 col10 file0 @@ -4117,12 +3855,12 @@ - line232 + line222 col10 file0 - line232 + line222 col30 file0 @@ -4138,7 +3876,7 @@ kindevent location - line214 + line204 col1 file0 @@ -4156,12 +3894,12 @@ start - line214 + line204 col1 file0 - line214 + line204 col1 file0 @@ -4169,12 +3907,12 @@ end - line215 + line205 col3 file0 - line215 + line205 col6 file0 @@ -4186,7 +3924,7 @@ kindevent location - line215 + line205 col10 file0 @@ -4194,12 +3932,12 @@ - line215 + line205 col10 file0 - line215 + line205 col21 file0 @@ -4219,12 +3957,12 @@ start - line215 + line205 col3 file0 - line215 + line205 col6 file0 @@ -4232,12 +3970,12 @@ end - line216 + line206 col3 file0 - line216 + line206 col8 file0 @@ -4249,7 +3987,7 @@ kindevent location - line232 + line222 col10 file0 @@ -4257,12 +3995,12 @@ - line232 + line222 col10 file0 - line232 + line222 col30 file0 @@ -4282,12 +4020,12 @@ start - line232 + line222 col10 file0 - line232 + line222 col10 file0 @@ -4295,12 +4033,12 @@ end - line232 + line222 col3 file0 - line232 + line222 col4 file0 @@ -4316,12 +4054,12 @@ start - line232 + line222 col3 file0 - line232 + line222 col4 file0 @@ -4329,12 +4067,12 @@ end - line237 + line227 col3 file0 - line237 + line227 col4 file0 @@ -4350,12 +4088,12 @@ start - line237 + line227 col3 file0 - line237 + line227 col4 file0 @@ -4363,12 +4101,12 @@ end - line237 + line227 col11 file0 - line237 + line227 col11 file0 @@ -4380,7 +4118,7 @@ kindevent location - line237 + line227 col11 file0 @@ -4388,12 +4126,12 @@ - line237 + line227 col11 file0 - line237 + line227 col23 file0 @@ -4417,7 +4155,7 @@ issue_hash_function_offset8 location - line237 + line227 col11 file0 @@ -4429,7 +4167,7 @@ kindevent location - line247 + line237 col22 file0 @@ -4437,12 +4175,12 @@ - line247 + line237 col22 file0 - line247 + line237 col40 file0 @@ -4462,12 +4200,12 @@ start - line247 + line237 col3 file0 - line247 + line237 col11 file0 @@ -4475,12 +4213,12 @@ end - line248 + line238 col3 file0 - line248 + line238 col15 file0 @@ -4492,7 +4230,7 @@ kindevent location - line248 + line238 col3 file0 @@ -4500,24 +4238,24 @@ - line248 + line238 col3 file0 - line248 + line238 col23 file0 - line248 + line238 col17 file0 - line248 + line238 col22 file0 @@ -4537,12 +4275,12 @@ start - line248 + line238 col3 file0 - line248 + line238 col15 file0 @@ -4550,12 +4288,12 @@ end - line249 + line239 col3 file0 - line249 + line239 col15 file0 @@ -4567,7 +4305,7 @@ kindevent location - line249 + line239 col3 file0 @@ -4575,24 +4313,24 @@ - line249 + line239 col3 file0 - line249 + line239 col23 file0 - line249 + line239 col17 file0 - line249 + line239 col22 file0 @@ -4612,12 +4350,12 @@ start - line249 + line239 col3 file0 - line249 + line239 col15 file0 @@ -4625,12 +4363,12 @@ end - line250 + line240 col3 file0 - line250 + line240 col8 file0 @@ -4642,7 +4380,7 @@ kindevent location - line250 + line240 col3 file0 @@ -4650,12 +4388,12 @@ - line250 + line240 col3 file0 - line250 + line240 col8 file0 @@ -4679,7 +4417,7 @@ issue_hash_function_offset4 location - line250 + line240 col3 file0 @@ -4691,7 +4429,7 @@ kindevent location - line254 + line244 col22 file0 @@ -4699,12 +4437,12 @@ - line254 + line244 col22 file0 - line254 + line244 col37 file0 @@ -4724,12 +4462,12 @@ start - line254 + line244 col3 file0 - line254 + line244 col11 file0 @@ -4737,12 +4475,12 @@ end - line255 + line245 col3 file0 - line255 + line245 col15 file0 @@ -4754,7 +4492,7 @@ kindevent location - line255 + line245 col3 file0 @@ -4762,24 +4500,24 @@ - line255 + line245 col3 file0 - line255 + line245 col23 file0 - line255 + line245 col17 file0 - line255 + line245 col22 file0 @@ -4799,12 +4537,12 @@ start - line255 + line245 col3 file0 - line255 + line245 col15 file0 @@ -4812,12 +4550,12 @@ end - line256 + line246 col3 file0 - line256 + line246 col8 file0 @@ -4829,7 +4567,7 @@ kindevent location - line256 + line246 col3 file0 @@ -4837,12 +4575,12 @@ - line256 + line246 col3 file0 - line256 + line246 col8 file0 @@ -4866,7 +4604,7 @@ issue_hash_function_offset3 location - line256 + line246 col3 file0 @@ -4878,7 +4616,7 @@ kindevent location - line260 + line250 col22 file0 @@ -4886,12 +4624,12 @@ - line260 + line250 col22 file0 - line260 + line250 col37 file0 @@ -4911,12 +4649,12 @@ start - line260 + line250 col3 file0 - line260 + line250 col11 file0 @@ -4924,12 +4662,12 @@ end - line261 + line251 col3 file0 - line261 + line251 col15 file0 @@ -4941,7 +4679,7 @@ kindevent location - line261 + line251 col3 file0 @@ -4949,24 +4687,24 @@ - line261 + line251 col3 file0 - line261 + line251 col23 file0 - line261 + line251 col17 file0 - line261 + line251 col22 file0 @@ -4986,12 +4724,12 @@ start - line261 + line251 col3 file0 - line261 + line251 col15 file0 @@ -4999,12 +4737,12 @@ end - line262 + line252 col3 file0 - line262 + line252 col3 file0 @@ -5016,7 +4754,7 @@ kindevent location - line262 + line252 col3 file0 @@ -5024,24 +4762,24 @@ - line262 + line252 col3 file0 - line262 + line252 col26 file0 - line262 + line252 col4 file0 - line262 + line252 col13 file0 @@ -5061,12 +4799,12 @@ start - line262 + line252 col3 file0 - line262 + line252 col3 file0 @@ -5074,12 +4812,12 @@ end - line263 + line253 col3 file0 - line263 + line253 col8 file0 @@ -5091,7 +4829,7 @@ kindevent location - line263 + line253 col3 file0 @@ -5099,12 +4837,12 @@ - line263 + line253 col3 file0 - line263 + line253 col8 file0 @@ -5128,11 +4866,11 @@ issue_hash_function_offset4 location - line263 + line253 col3 file0 - + \ No newline at end of file Index: cfe/trunk/test/Analysis/PR2599.m =================================================================== --- cfe/trunk/test/Analysis/PR2599.m +++ cfe/trunk/test/Analysis/PR2599.m @@ -1,63 +0,0 @@ -// RUN: %clang_analyze_cc1 -triple %itanium_abi_triple -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -fobjc-gc -verify %s - -typedef const void * CFTypeRef; -typedef const struct __CFString * CFStringRef; -typedef const struct __CFAllocator * CFAllocatorRef; -typedef const struct __CFDictionary * CFDictionaryRef; -CFTypeRef CFMakeCollectable(CFTypeRef cf) ; -extern CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...); -typedef signed char BOOL; -typedef unsigned int NSUInteger; -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)autorelease; -@end -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end @protocol NSMutableCopying -- (id)mutableCopyWithZone:(NSZone *)zone; -@end -@protocol -NSCoding -- (void)encodeWithCoder:(NSCoder *)aCoder; -@end -@interface NSObject {} -- (id)init; -+ (id)alloc; -@end -enum { NSASCIIStringEncoding = 1, NSNEXTSTEPStringEncoding = 2, NSJapaneseEUCStringEncoding = 3, NSUTF8StringEncoding = 4, NSISOLatin1StringEncoding = 5, NSSymbolStringEncoding = 6, NSNonLossyASCIIStringEncoding = 7, NSShiftJISStringEncoding = 8, NSISOLatin2StringEncoding = 9, NSUnicodeStringEncoding = 10, NSWindowsCP1251StringEncoding = 11, NSWindowsCP1252StringEncoding = 12, NSWindowsCP1253StringEncoding = 13, NSWindowsCP1254StringEncoding = 14, NSWindowsCP1250StringEncoding = 15, NSISO2022JPStringEncoding = 21, NSMacOSRomanStringEncoding = 30, NSUTF16StringEncoding = NSUnicodeStringEncoding, NSUTF16BigEndianStringEncoding = 0x90000100, NSUTF16LittleEndianStringEncoding = 0x94000100, NSUTF32StringEncoding = 0x8c000100, NSUTF32BigEndianStringEncoding = 0x98000100, NSUTF32LittleEndianStringEncoding = 0x9c000100 }; -typedef NSUInteger NSStringEncoding; -@interface NSString : NSObject -- (NSUInteger)length; -- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeBuffer; -@end -@interface NSAutoreleasePool : NSObject {} -- (void)drain; -@end -extern NSString * const NSXMLParserErrorDomain ; - -// The actual test case. UTIL_AUTORELEASE_CF_AS_ID is a macro that doesn't -// actually do what it was intended to. - -#define NSSTRINGWRAPPER(bytes,len) \ - [[[NSString alloc] initWithBytesNoCopy: (void*)(bytes) length: (len) encoding: NSUTF8StringEncoding freeWhenDone: (BOOL)0] autorelease] - -#define UTIL_AUTORELEASE_CF_AS_ID(cf) ( (((void*)0) == (cf)) ? ((void*)0) : [(id) CFMakeCollectable( (CFTypeRef) cf) autorelease] ) - -#define UTIL_AUTORELEASE_CF_AS_ID_WITHOUT_TEST(cf) ( [(id) CFMakeCollectable( (CFTypeRef) cf) autorelease] ) - -static char *lorem = "fooBarBaz"; - -void NSLog(NSString *, ...); - -int main (int argc, const char * argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSString *tmp1 = NSSTRINGWRAPPER(lorem, 6); // no-warning - NSString *tmp2 = UTIL_AUTORELEASE_CF_AS_ID( CFStringCreateWithFormat(((void*)0), ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "lorem: %@" "")), tmp1) ); // expected-warning 2 {{leak}} - NSString *tmp3 = UTIL_AUTORELEASE_CF_AS_ID_WITHOUT_TEST( CFStringCreateWithFormat(((void*)0), ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "lorem: %@" "")), tmp1) ); - NSLog(@"tmp2: %@ tmp3: %@", tmp2, tmp3); - [pool drain]; - return 0; -} Index: cfe/trunk/test/Analysis/retain-release-gc-only.m =================================================================== --- cfe/trunk/test/Analysis/retain-release-gc-only.m +++ cfe/trunk/test/Analysis/retain-release-gc-only.m @@ -1,434 +0,0 @@ -// RUN: %clang_analyze_cc1 -triple %itanium_abi_triple -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify -Wno-objc-root-class %s - -//===----------------------------------------------------------------------===// -// Header stuff. -//===----------------------------------------------------------------------===// - -typedef unsigned int __darwin_natural_t; -typedef unsigned long uintptr_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -typedef unsigned int UInt32; -typedef signed long CFIndex; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; -static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) { - CFRange range; - range.location = loc; - range.length = len; - return range; -} -typedef const void * CFTypeRef; -typedef const struct __CFString * CFStringRef; -typedef const struct __CFAllocator * CFAllocatorRef; -extern const CFAllocatorRef kCFAllocatorDefault; -extern CFTypeRef CFRetain(CFTypeRef cf); -extern void CFRelease(CFTypeRef cf); -typedef struct { -} -CFArrayCallBacks; -extern const CFArrayCallBacks kCFTypeArrayCallBacks; -typedef const struct __CFArray * CFArrayRef; -typedef struct __CFArray * CFMutableArrayRef; -extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks); -extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx); -extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); -typedef struct { -} -CFDictionaryKeyCallBacks; -extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; -typedef struct { -} -CFDictionaryValueCallBacks; -extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; -extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); -typedef UInt32 CFStringEncoding; -enum { -kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 }; -extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding); -typedef double CFTimeInterval; -typedef CFTimeInterval CFAbsoluteTime; -extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); -typedef const struct __CFDate * CFDateRef; -extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); -extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); -typedef __darwin_natural_t natural_t; -typedef natural_t mach_port_name_t; -typedef mach_port_name_t mach_port_t; -typedef int kern_return_t; -typedef kern_return_t mach_error_t; -enum { -kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 }; -typedef CFIndex CFNumberType; -typedef const struct __CFNumber * CFNumberRef; -extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; -extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) ; -extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) ; -extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ; -typedef signed char BOOL; -typedef unsigned long NSUInteger; -@class NSString, Protocol; -extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -- (id)autorelease; -- (Class)class; -@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone; -@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; -@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; -@end -@interface NSObject {} -+ (id)allocWithZone:(NSZone *)zone; -+ (id)alloc; -- (void)dealloc; -- (oneway void)release; -- (id)copy; -@end -@interface NSObject (NSCoderMethods) -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder; -@end -extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); -typedef struct { -} -NSFastEnumerationState; -@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end @class NSString, NSDictionary; -@interface NSValue : NSObject - (void)getValue:(void *)value; -@end @interface NSNumber : NSValue - (char)charValue; -- (id)initWithInt:(int)value; -@end @class NSString; -@interface NSArray : NSObject -- (NSUInteger)count; -@end -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; -@end - @interface NSAutoreleasePool : NSObject { -} -- (void)drain; -- (id)init; -@end extern NSString * const NSBundleDidLoadNotification; -typedef double NSTimeInterval; -@interface NSDate : NSObject - (NSTimeInterval)timeIntervalSinceReferenceDate; -@end typedef unsigned short unichar; -@interface NSString : NSObject - (NSUInteger)length; -- ( const char *)UTF8String; -- (id)initWithUTF8String:(const char *)nullTerminatedCString; -+ (id)stringWithUTF8String:(const char *)nullTerminatedCString; -@end @class NSString, NSURL, NSError; -@interface NSData : NSObject - (NSUInteger)length; -+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; -+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; -@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary; -@interface NSDictionary : NSObject - (NSUInteger)count; -@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; -- (void)setObject:(id)anObject forKey:(id)aKey; -@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems; -@end typedef double CGFloat; -struct CGSize { -}; -typedef struct CGSize CGSize; -struct CGRect { -}; -typedef struct CGRect CGRect; -typedef mach_port_t io_object_t; -typedef char io_name_t[128]; -typedef io_object_t io_iterator_t; -typedef io_object_t io_service_t; -typedef struct IONotificationPort * IONotificationPortRef; -typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator ); -io_service_t IOServiceGetMatchingService( mach_port_t masterPort, CFDictionaryRef matching ); -kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing ); -kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); -kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification ); -CFMutableDictionaryRef IOServiceMatching( const char * name ); -CFMutableDictionaryRef IOServiceNameMatching( const char * name ); -CFMutableDictionaryRef IOBSDNameMatching( mach_port_t masterPort, uint32_t options, const char * bsdName ); -CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, uint32_t options, const char * path ); -CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID ); -typedef struct __DASession * DASessionRef; -extern DASessionRef DASessionCreate( CFAllocatorRef allocator ); -typedef struct __DADisk * DADiskRef; -extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name ); -extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media ); -extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk ); -extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk ); -@interface NSTask : NSObject - (id)init; -@end typedef struct CGColorSpace *CGColorSpaceRef; -typedef struct CGImage *CGImageRef; -typedef struct CGLayer *CGLayerRef; -@interface NSResponder : NSObject { -} -@end @protocol NSAnimatablePropertyContainer - (id)animator; -@end extern NSString *NSAnimationTriggerOrderIn ; -@interface NSView : NSResponder { -} -@end @protocol NSValidatedUserInterfaceItem - (SEL)action; -@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id )anItem; -@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; -@interface NSApplication : NSResponder { -} -@end enum { -NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; -typedef NSUInteger NSApplicationTerminateReply; -@protocol NSApplicationDelegate @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; -@interface NSCell : NSObject { -} -@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; -typedef struct { -} -CVTimeStamp; -@interface CIImage : NSObject { -} -typedef int CIFormat; -@end enum { -kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C }; -typedef mach_error_t DAReturn; -typedef const struct __DADissenter * DADissenterRef; -extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string ); -@interface CIContext: NSObject { -} -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r; -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs; -- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d; -@end extern NSString* const QCRendererEventKey; -@protocol QCCompositionRenderer - (NSDictionary*) attributes; -@end @interface QCRenderer : NSObject { -} -- (id) createSnapshotImageOfType:(NSString*)type; -@end extern NSString* const QCViewDidStartRenderingNotification; -@interface QCView : NSView { -} -- (id) createSnapshotImageOfType:(NSString*)type; -@end enum { -ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, }; -@class ICDevice; -@protocol ICDeviceDelegate @required - (void)didRemoveDevice:(ICDevice*)device; -@end extern NSString *const ICScannerStatusWarmingUp; -@class ICScannerDevice; -@protocol ICScannerDeviceDelegate @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner; -@end -CFTypeRef CFMakeCollectable(CFTypeRef cf) ; - -static __inline__ __attribute__((always_inline)) id NSMakeCollectable(CFTypeRef -cf) { - return cf ? (id)CFMakeCollectable(cf) : ((void*)0); -} - -//===----------------------------------------------------------------------===// -// Test cases. -//===----------------------------------------------------------------------===// - -void f1() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning - id x = [(id) A autorelease]; - CFRelease((CFMutableArrayRef) x); -} - -void f2() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}} - id x = [(id) A retain]; - [x release]; - [x release]; -} - -void f3() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}} - CFMakeCollectable(A); - CFRetain(A); -} - -void f3b() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning - CFMakeCollectable(A); -} - - -void f4() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}} - NSMakeCollectable(A); - CFRetain(A); -} - -void f4b() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning - NSMakeCollectable(A); -} - -void f5() { - id x = [NSMakeCollectable(CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks)) autorelease]; // no-warning -} - -void f5b() { - id x = [(id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks) autorelease]; // expected-warning{{leak}} -} - -// Test return of non-owned objects in contexts where an owned object -// is expected. -@interface TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString; -- (CFMutableArrayRef)newArray; -@end - -@implementation TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString { - NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object}} - CFRetain(s); - return s; -} -- (CFMutableArrayRef)newArray{ - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// False positive: object substitution during -init* -// methods warns about returning +0 when using -fobjc-gc-only -//===----------------------------------------------------------------------===// - -@interface MyClassRdar6948053 : NSObject -- (id) init; -+ (id) shared; -@end - -@implementation MyClassRdar6948053 -+(id) shared { - return (id) 0; -} -- (id) init -{ - Class myClass = [self class]; - [self release]; - return [[myClass shared] retain]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// 'ciContext createCGImage:outputImage fromRect:' returns a retained CF object (not GC'ed)//===----------------------------------------------------------------------===// -//===----------------------------------------------------------------------===// - -void rdar_7174400(QCView *view, QCRenderer *renderer, CIContext *context, - NSString *str, CIImage *img, CGRect rect, - CIFormat form, CGColorSpaceRef cs) { - [view createSnapshotImageOfType:str]; // no-warning - [renderer createSnapshotImageOfType:str]; // no-warning - [context createCGImage:img fromRect:rect]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// Warn against using -[NSAutoreleasePool release] in -// GC mode -//===----------------------------------------------------------------------===// - -void rdar_6250216(void) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - [pool release]; // expected-warning{{Use -drain instead of -release when using NSAutoreleasePool and garbage collection}} -} - - -//===----------------------------------------------------------------------===// -// Don't crash when analyzing messages sent to blocks -//===----------------------------------------------------------------------===// - -@class RDar7407273; -typedef void (^RDar7407273Block)(RDar7407273 *operation); -void rdar7407273(RDar7407273Block b) { - [b copy]; -} - -//===----------------------------------------------------------------------===// -// Tests of ownership attributes. -//===----------------------------------------------------------------------===// - -@interface TestOwnershipAttr : NSObject -- (NSString*) returnsAnOwnedString __attribute__((ns_returns_retained)); -- (NSString*) returnsAnOwnedCFString __attribute__((cf_returns_retained)); -@end - -void test_attr_1(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedString]; // no-warning -} - -void test_attr_1b(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}} -} - -@interface MyClassTestCFAttr : NSObject {} -- (NSDate*) returnsCFRetained __attribute__((cf_returns_retained)); -- (NSDate*) alsoReturnsRetained; -- (NSDate*) returnsNSRetained __attribute__((ns_returns_retained)); -@end - -__attribute__((cf_returns_retained)) -CFDateRef returnsRetainedCFDate() { - return CFDateCreate(0, CFAbsoluteTimeGetCurrent()); -} - -@implementation MyClassTestCFAttr -- (NSDate*) returnsCFRetained { - return (NSDate*) returnsRetainedCFDate(); // No leak. -} - -- (NSDate*) alsoReturnsRetained { - return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} -} - -- (NSDate*) returnsNSRetained { - return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} -} -@end - - -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif - -void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); -void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void)); - -void testConsumeAndStopTracking() { - id retained = [@[] retain]; // +0, GC - consumeAndStopTracking(retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +0, GC - consumeAndStopTracking(doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - consumeAndStopTracking(unretained, ^{}); // no-warning, GC -} - -void testCFConsumeAndStopTrackingMsg() { - id retained = [@[] retain]; // +0, GC - CFConsumeAndStopTracking((CFTypeRef)retained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -void testCFConsumeAndStopTracking() { - CFTypeRef retained = returnsRetainedCFDate(); // +1 - CFConsumeAndStopTracking(retained, ^{}); // no-warning - - CFTypeRef doubleRetained = CFRetain(returnsRetainedCFDate()); // +2 - CFConsumeAndStopTracking(doubleRetained, ^{ - CFRelease(doubleRetained); - }); // no-warning - - id unretained = @[]; // +0 - CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} Index: cfe/trunk/test/Analysis/retain-release-path-notes-gc.m =================================================================== --- cfe/trunk/test/Analysis/retain-release-path-notes-gc.m +++ cfe/trunk/test/Analysis/retain-release-path-notes-gc.m @@ -1,75 +0,0 @@ -// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=text -verify %s -// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=plist-multi-file %s -o %t.plist -// RUN: tail -n +11 %t.plist | diff -u -w - %S/Inputs/expected-plists/retain-release-path-notes-gc.m.plist - -/*** -This file is for testing the path-sensitive notes for retain/release errors. -Its goal is to have simple branch coverage of any path-based diagnostics, -not to actually check all possible retain/release errors. - -This file is for notes that only appear in a GC-enabled analysis. -Non-specific and ref-count-only notes should go in retain-release-path-notes.m. -***/ - -@interface NSObject -+ (id)alloc; -- (id)init; -- (void)dealloc; - -- (Class)class; - -- (id)retain; -- (void)release; -- (void)autorelease; -@end - -@interface Foo : NSObject -- (id)methodWithValue; -@property(retain) id propertyValue; -@end - -typedef struct CFType *CFTypeRef; -CFTypeRef CFRetain(CFTypeRef); -void CFRelease(CFTypeRef); - -id NSMakeCollectable(CFTypeRef); -CFTypeRef CFMakeCollectable(CFTypeRef); - -CFTypeRef CFCreateSomething(); -CFTypeRef CFGetSomething(); - - -void creationViaCFCreate () { - CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected}} - return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} -} - -void makeCollectable () { - CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected}} - CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +2 retain count}} - CFMakeCollectable(leaked); // expected-note{{In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1}} - NSMakeCollectable(leaked); // expected-note{{In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector}} - CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again}} - return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} -} - -void retainReleaseIgnored () { - id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +0 retain count}} - [object retain]; // expected-note{{In GC mode the 'retain' message has no effect}} - [object release]; // expected-note{{In GC mode the 'release' message has no effect}} - [object autorelease]; // expected-note{{In GC mode an 'autorelease' has no effect}} - CFRelease((CFTypeRef)object); // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -@implementation Foo (FundamentalRuleUnderGC) -- (id)getViolation { - id object = (id) CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected}} - return object; // expected-warning{{leak}} expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}} -} - -- (id)copyViolation { - id object = (id) CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected}} - return object; // expected-warning{{leak}} expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}} -} -@end - Index: cfe/trunk/test/Analysis/retain-release-path-notes.m =================================================================== --- cfe/trunk/test/Analysis/retain-release-path-notes.m +++ cfe/trunk/test/Analysis/retain-release-path-notes.m @@ -36,9 +36,6 @@ void CFRelease(CFTypeRef); CFTypeRef CFAutorelease(CFTypeRef __attribute__((cf_consumed))); -id NSMakeCollectable(CFTypeRef); -CFTypeRef CFMakeCollectable(CFTypeRef); - CFTypeRef CFCreateSomething(); CFTypeRef CFGetSomething(); @@ -98,13 +95,6 @@ return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased but has a +0 retain count}} } -void makeCollectableIgnored () { - CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}} - CFMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument}} - NSMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument}} - return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} -} - CFTypeRef CFCopyRuleViolation () { CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}} return object; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} Index: cfe/trunk/test/Analysis/retain-release.m =================================================================== --- cfe/trunk/test/Analysis/retain-release.m +++ cfe/trunk/test/Analysis/retain-release.m @@ -318,9 +318,6 @@ + (id)array; @end -// This is how NSMakeCollectable is declared in the OS X 10.8 headers. -id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained)); - typedef const struct __CFUUID * CFUUIDRef; extern @@ -2076,17 +2073,6 @@ } } -id makeCollectableNonLeak() { - extern CFTypeRef CFCreateSomething(); - - CFTypeRef object = CFCreateSomething(); // +1 - CFRetain(object); // +2 - id objCObject = NSMakeCollectable(object); // +2 - [objCObject release]; // +1 - return [objCObject autorelease]; // +0 -} - - void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void));