std::unique_ptr<BugType> ExtraReleaseBugType;
std::unique_ptr<BugType> MistakenDeallocBugType;
- // FIXME: constexpr initialization isn't supported by MSVC2013.
- static const char *const MsgDeclared;
- static const char *const MsgSynthesized;
-
public:
ObjCDeallocChecker();
void checkEndFunction(CheckerContext &Ctx) const;
private:
- void addNoteForDecl(std::unique_ptr<BugReport> &BR, StringRef Msg,
- const Decl *D) const;
-
void diagnoseMissingReleases(CheckerContext &C) const;
bool diagnoseExtraRelease(SymbolRef ReleasedValue, const ObjCMethodCall &M,
typedef llvm::ImmutableSet<SymbolRef> SymbolSet;
-const char *const ObjCDeallocChecker::MsgDeclared =
- "Property is declared here";
-const char *const ObjCDeallocChecker::MsgSynthesized =
- "Property is synthesized here";
-
/// Maps from the symbol for a class instance to the set of
/// symbols remaining that must be released in -dealloc.
REGISTER_MAP_WITH_PROGRAMSTATE(UnreleasedIvarMap, SymbolRef, SymbolSet)
return State;
}
-/// Add an extra note piece describing a declaration that is important
-/// for understanding the bug report.
-void ObjCDeallocChecker::addNoteForDecl(std::unique_ptr<BugReport> &BR,
- StringRef Msg,
- const Decl *D) const {
- ASTContext &ACtx = D->getASTContext();
- SourceManager &SM = ACtx.getSourceManager();
- PathDiagnosticLocation Pos = PathDiagnosticLocation::createBegin(D, SM);
- if (Pos.isValid() && Pos.asLocation().isValid())
- BR->addNote(Msg, Pos, D->getSourceRange());
-}
-
/// Report any unreleased instance variables for the current instance being
/// dealloced.
void ObjCDeallocChecker::diagnoseMissingReleases(CheckerContext &C) const {
std::unique_ptr<BugReport> BR(
new BugReport(*MissingReleaseBugType, OS.str(), ErrNode));
- addNoteForDecl(BR, MsgDeclared, PropDecl);
- addNoteForDecl(BR, MsgSynthesized, PropImpl);
-
C.emitReport(std::move(BR));
}
);
const ObjCImplDecl *Container = getContainingObjCImpl(C.getLocationContext());
- const ObjCIvarDecl *IvarDecl = PropImpl->getPropertyIvarDecl();
- OS << "The '" << *IvarDecl << "' ivar in '" << *Container;
+ OS << "The '" << *PropImpl->getPropertyIvarDecl()
+ << "' ivar in '" << *Container;
- bool ReleasedByCIFilterDealloc = isReleasedByCIFilterDealloc(PropImpl);
- if (ReleasedByCIFilterDealloc) {
+ if (isReleasedByCIFilterDealloc(PropImpl)) {
OS << "' will be released by '-[CIFilter dealloc]' but also released here";
} else {
OS << "' was synthesized for ";
new BugReport(*ExtraReleaseBugType, OS.str(), ErrNode));
BR->addRange(M.getOriginExpr()->getSourceRange());
- addNoteForDecl(BR, MsgDeclared, PropDecl);
- if (!ReleasedByCIFilterDealloc)
- addNoteForDecl(BR, MsgSynthesized, PropImpl);
-
C.emitReport(std::move(BR));
return true;
@interface MyPropertyClass1 : NSObject
@property (copy) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation MyPropertyClass1
@interface MyPropertyClass2 : NSObject
@property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation MyPropertyClass2
NSObject *_ivar;
}
@property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation MyPropertyClass3
@synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is synthesized here}}
-#endif
- (void)dealloc
{
#if NON_ARC
void (^_blockPropertyIvar)(void);
}
@property (copy) void (^blockProperty)(void);
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@property (copy) void (^blockProperty2)(void);
@property (copy) void (^blockProperty3)(void);
@implementation MyPropertyClass4
@synthesize blockProperty = _blockPropertyIvar;
-#if NON_ARC
-// expected-note@-2 {{Property is synthesized here}}
-#endif
- (void)dealloc
{
#if NON_ARC
NSObject *_ivar;
}
@property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation MyPropertyClassWithReturnInDealloc
@synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is synthesized here}}
-#endif
- (void)dealloc
{
return;
MyPropertyClassWithReleaseInOtherInstance *_other;
}
@property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
-(void)releaseIvars;
@end
@implementation MyPropertyClassWithReleaseInOtherInstance
@synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is synthesized here}}
-#endif
-(void)releaseIvars; {
#if NON_ARC
NSObject *_ivar;
}
@property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation MyPropertyClassWithNeitherReturnNorSuperDealloc
@synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is synthesized here}}
-#endif
- (void)dealloc
{
}
BOOL _ivar1;
}
@property (retain) NSObject *ivar2;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation ClassWithControlFlowInRelease
@interface ClassWithNildOutIvar : NSObject
@property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation ClassWithNildOutIvar
@interface ClassWithUpdatedIvar : NSObject
@property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation ClassWithUpdatedIvar
@property (retain) NSObject *propNilledOutInFunction;
@property (retain) NSObject *ivarNeverReleased;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
- (void)invalidateInMethod;
@end
@interface ClassWhereSelfEscapesViaSynthesizedPropertyAccess : NSObject
@property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@property (retain) NSObject *otherIvar;
@end
@interface ClassWhereSelfEscapesViaCallToSystem : NSObject
@property (retain) NSObject *ivar1;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@property (retain) NSObject *ivar2;
@property (retain) NSObject *ivar3;
@property (retain) NSObject *ivar4;
@interface SuperClassOfClassWithInlinedSuperDealloc : NSObject
@property (retain) NSObject *propInSuper;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation SuperClassOfClassWithInlinedSuperDealloc
@interface ClassWithInlinedSuperDealloc : SuperClassOfClassWithInlinedSuperDealloc
@property (retain) NSObject *propInSub;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation ClassWithInlinedSuperDealloc
@interface SuperClassOfClassThatEscapesBeforeInliningSuper : NSObject
@property (retain) NSObject *propInSuper;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation SuperClassOfClassThatEscapesBeforeInliningSuper
@property(retain) NSObject *inputIvar;
@property(retain) NSObject *nonInputIvar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@property(retain) NSObject *inputAutoSynthesizedIvar;
@property(retain) NSObject *inputExplicitlySynthesizedToNonPrefixedIvar;
@property(retain) NSObject *nonPrefixedPropertyBackedByExplicitlySynthesizedPrefixedIvar;
@implementation ImmediateSubCIFilter
@synthesize inputIvar = inputIvar;
@synthesize nonInputIvar = nonInputIvar;
-#if NON_ARC
-// expected-note@-2 {{Property is synthesized here}}
-#endif
@synthesize inputExplicitlySynthesizedToNonPrefixedIvar = notPrefixedButBackingPrefixedProperty;
@synthesize nonPrefixedPropertyBackedByExplicitlySynthesizedPrefixedIvar = inputPrefixedButBackingNonPrefixedProperty;
}
@property(retain) NSObject *inputIvar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation OverreleasingCIFilter
}
@property (readonly, retain) NSObject *ivarForOutlet;
-#if NON_ARC && !MACOS
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation ClassWithRetainPropWithIBOutletIvarButNoSetter
@synthesize ivarForOutlet;
-#if NON_ARC && !MACOS
-// expected-note@-2 {{Property is synthesized here}}
-#endif
- (void)dealloc {
#if NON_ARC
// setter and so the ivar will be retained by nib-loading code even on
// macOS and therefore must be released.
@property (readwrite, retain) NSObject *ivarForOutlet;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
@end
@implementation ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite
@synthesize ivarForOutlet;
-#if NON_ARC
-// expected-note@-2 {{Property is synthesized here}}
-#endif
- (void)dealloc {
#if NON_ARC