]> granicus.if.org Git - clang/commitdiff
Revert "[analyzer] Add extra notes to ObjCDeallocChecker" as its depends on reverted...
authorVitaly Buka <vitalybuka@google.com>
Tue, 4 Oct 2016 02:36:58 +0000 (02:36 +0000)
committerVitaly Buka <vitalybuka@google.com>
Tue, 4 Oct 2016 02:36:58 +0000 (02:36 +0000)
This reverts commit r283093.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283181 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
test/Analysis/DeallocMissingRelease.m
test/Analysis/PR2978.m
test/Analysis/properties.m

index 8fd36b828663a1689ea083a09b9464cffba0a0e7..ffb0adc8d636b63129503ad8fb95f5b61a5d01d1 100644 (file)
@@ -107,9 +107,6 @@ class ObjCDeallocChecker
   std::unique_ptr<BugType> ExtraReleaseBugType;
   std::unique_ptr<BugType> MistakenDeallocBugType;
 
-  static constexpr const char *MsgDeclared = "Property is declared here";
-  static constexpr const char *MsgSynthesized = "Property is synthesized here";
-
 public:
   ObjCDeallocChecker();
 
@@ -131,9 +128,6 @@ public:
   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,
@@ -495,18 +489,6 @@ ProgramStateRef ObjCDeallocChecker::checkPointerEscape(
   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 {
@@ -604,9 +586,6 @@ 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));
   }
 
@@ -710,12 +689,11 @@ bool ObjCDeallocChecker::diagnoseExtraRelease(SymbolRef ReleasedValue,
          );
 
   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 ";
@@ -732,10 +710,6 @@ bool ObjCDeallocChecker::diagnoseExtraRelease(SymbolRef ReleasedValue,
       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;
index 224f44c1d1ec89994b4924151de9162208712e13..009e80151814e110f13c5b0bda1e835fd747666c 100644 (file)
@@ -80,9 +80,6 @@
 
 @interface MyPropertyClass1 : NSObject
 @property (copy) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClass1
@@ -96,9 +93,6 @@
 
 @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
 
@@ -473,9 +425,6 @@ void NilOutPropertyHelper(ClassWithDeallocHelpers *o) {
 
 @interface ClassWhereSelfEscapesViaSynthesizedPropertyAccess : NSObject
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @property (retain) NSObject *otherIvar;
 @end
 
@@ -493,9 +442,6 @@ void NilOutPropertyHelper(ClassWithDeallocHelpers *o) {
 
 @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;
@@ -590,9 +536,6 @@ void ReleaseMe(id arg);
 
 @interface SuperClassOfClassWithInlinedSuperDealloc : NSObject
 @property (retain) NSObject *propInSuper;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @end
 
 @implementation SuperClassOfClassWithInlinedSuperDealloc
@@ -605,9 +548,6 @@ void ReleaseMe(id arg);
 
 @interface ClassWithInlinedSuperDealloc : SuperClassOfClassWithInlinedSuperDealloc
 @property (retain) NSObject *propInSub;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @end
 
 @implementation ClassWithInlinedSuperDealloc
@@ -665,9 +605,6 @@ void ReleaseMe(id arg);
 
 @interface SuperClassOfClassThatEscapesBeforeInliningSuper : NSObject
 @property (retain) NSObject *propInSuper;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @end
 
 @implementation SuperClassOfClassThatEscapesBeforeInliningSuper
@@ -857,9 +794,6 @@ __attribute__((objc_root_class))
 
 @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;
@@ -869,9 +803,6 @@ __attribute__((objc_root_class))
 @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;
 
@@ -910,9 +841,6 @@ __attribute__((objc_root_class))
 }
 
 @property(retain) NSObject *inputIvar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @end
 
 @implementation OverreleasingCIFilter
index 379fe6c0473674fd91dd233b8a58a12b2a274d19..b609da5aac24ba678c33c4f7f51e95bb63733ac5 100644 (file)
   id _nonPropertyIvar;
 }
 @property(retain) id X;
-@property(retain) id Y; // expected-note{{Property is declared here}}
-@property(assign) id Z; // expected-note{{Property is declared here}}
+@property(retain) id Y;
+@property(assign) id Z;
 @property(assign) id K;
 @property(weak) id L;
 @property(readonly) id N;
 @property(retain) id M;
 @property(weak) id P;
-@property(weak) id Q; // expected-note{{Property is declared here}}
+@property(weak) id Q;
 @property(retain) id R;
-@property(weak, readonly) id S; // expected-note{{Property is declared here}}
+@property(weak, readonly) id S;
 
 @property(assign, readonly) id T; // Shadowed in class extension
 @property(assign) id U;
 
 @property(retain) id V;
-@property(retain) id W; // expected-note{{Property is declared here}}
+@property(retain) id W;
 -(id) O;
 -(void) setO: (id) arg;
 @end
 
 @implementation MyClass
 @synthesize X = _X;
-@synthesize Y = _Y; // expected-note{{Property is synthesized here}}
-@synthesize Z = _Z; // expected-note{{Property is synthesized here}}
+@synthesize Y = _Y;
+@synthesize Z = _Z;
 @synthesize K = _K;
 @synthesize L = _L;
 @synthesize N = _N;
 @synthesize M = _M;
-@synthesize Q = _Q; // expected-note{{Property is synthesized here}}
+@synthesize Q = _Q;
 @synthesize R = _R;
 @synthesize V = _V;
-@synthesize W = _W; // expected-note{{Property is synthesized here}}
+@synthesize W = _W;
 
 -(id) O{ return 0; }
 -(void) setO:(id)arg { }
index 55ea2c10be26f341de485d55372014be469f0a05..b1305341e5d4b9cd232e8efc9f9d8a0299c3042f 100644 (file)
@@ -134,17 +134,11 @@ NSNumber* numberFromMyNumberProperty(MyNumber* aMyNumber)
   NSString *_name;
 }
 @property (retain) NSString * name;
-#if !__has_feature(objc_arc)
-// expected-note@-2 {{Property is declared here}}
-#endif
 @property (assign) id friend;
 @end
 
 @implementation Person
 @synthesize name = _name;
-#if !__has_feature(objc_arc)
-// expected-note@-2 {{Property is synthesized here}}
-#endif
 
 -(void)dealloc {
 #if !__has_feature(objc_arc)