Index: clang/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h =================================================================== --- clang/include/clang/StaticAnalyzer/Checkers/ObjCRetainCount.h +++ clang/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: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ clang/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: clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist =================================================================== --- clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist +++ clang/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: clang/test/Analysis/retain-release-path-notes.m =================================================================== --- clang/test/Analysis/retain-release-path-notes.m +++ clang/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: clang/test/Analysis/retain-release.m =================================================================== --- clang/test/Analysis/retain-release.m +++ clang/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));