r284317 - Revert "[analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker""

Devin Coughlin via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 15 17:30:08 PDT 2016


Author: dcoughlin
Date: Sat Oct 15 19:30:08 2016
New Revision: 284317

URL: http://llvm.org/viewvc/llvm-project?rev=284317&view=rev
Log:
Revert "[analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker""

Revert:
r283662: [analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker"
r283660: [analyzer] Fix build error after r283660 - remove constexpr strings.

It was causing an internal build bot to fail. It looks like in some cases
adding an extra note can cause scan-build plist output to drop a diagnostic
altogether.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
    cfe/trunk/test/Analysis/DeallocMissingRelease.m
    cfe/trunk/test/Analysis/PR2978.m
    cfe/trunk/test/Analysis/properties.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=284317&r1=284316&r2=284317&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Sat Oct 15 19:30:08 2016
@@ -108,10 +108,6 @@ class ObjCDeallocChecker
   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();
 
@@ -133,9 +129,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,
@@ -187,11 +180,6 @@ private:
 
 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)
@@ -503,18 +491,6 @@ ProgramStateRef ObjCDeallocChecker::chec
   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 {
@@ -612,9 +588,6 @@ void ObjCDeallocChecker::diagnoseMissing
     std::unique_ptr<BugReport> BR(
         new BugReport(*MissingReleaseBugType, OS.str(), ErrNode));
 
-    addNoteForDecl(BR, MsgDeclared, PropDecl);
-    addNoteForDecl(BR, MsgSynthesized, PropImpl);
-
     C.emitReport(std::move(BR));
   }
 
@@ -718,12 +691,11 @@ bool ObjCDeallocChecker::diagnoseExtraRe
          );
 
   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 ";
@@ -740,10 +712,6 @@ bool ObjCDeallocChecker::diagnoseExtraRe
       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;

Modified: cfe/trunk/test/Analysis/DeallocMissingRelease.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocMissingRelease.m?rev=284317&r1=284316&r2=284317&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/DeallocMissingRelease.m (original)
+++ cfe/trunk/test/Analysis/DeallocMissingRelease.m Sat Oct 15 19:30:08 2016
@@ -81,9 +81,6 @@
 
 @interface MyPropertyClass1 : NSObject
 @property (copy) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClass1
@@ -97,9 +94,6 @@
 
 @interface MyPropertyClass2 : NSObject
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClass2
@@ -115,16 +109,10 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClass3
 @synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 - (void)dealloc
 {
 #if NON_ARC
@@ -138,9 +126,6 @@
   void (^_blockPropertyIvar)(void);
 }
 @property (copy) void (^blockProperty)(void);
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @property (copy) void (^blockProperty2)(void);
 @property (copy) void (^blockProperty3)(void);
 
@@ -148,9 +133,6 @@
 
 @implementation MyPropertyClass4
 @synthesize blockProperty = _blockPropertyIvar;
-#if NON_ARC
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 - (void)dealloc
 {
 #if NON_ARC
@@ -182,16 +164,10 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClassWithReturnInDealloc
 @synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 - (void)dealloc
 {
   return;
@@ -207,18 +183,12 @@
   MyPropertyClassWithReleaseInOtherInstance *_other;
 }
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 
 -(void)releaseIvars;
 @end
 
 @implementation MyPropertyClassWithReleaseInOtherInstance
 @synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 
 -(void)releaseIvars; {
 #if NON_ARC
@@ -239,16 +209,10 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClassWithNeitherReturnNorSuperDealloc
 @synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 - (void)dealloc
 {
 }
@@ -283,9 +247,6 @@
   BOOL _ivar1;
 }
 @property (retain) NSObject *ivar2;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation ClassWithControlFlowInRelease
@@ -327,9 +288,6 @@
 
 @interface ClassWithNildOutIvar : NSObject
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation ClassWithNildOutIvar
@@ -348,9 +306,6 @@
 
 @interface ClassWithUpdatedIvar : NSObject
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation ClassWithUpdatedIvar
@@ -395,9 +350,6 @@
 @property (retain) NSObject *propNilledOutInFunction;
 
 @property (retain) NSObject *ivarNeverReleased;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 - (void)invalidateInMethod;
 @end
 
@@ -474,9 +426,6 @@ void NilOutPropertyHelper(ClassWithDeall
 
 @interface ClassWhereSelfEscapesViaSynthesizedPropertyAccess : NSObject
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @property (retain) NSObject *otherIvar;
 @end
 
@@ -494,9 +443,6 @@ void NilOutPropertyHelper(ClassWithDeall
 
 @interface ClassWhereSelfEscapesViaCallToSystem : NSObject
 @property (retain) NSObject *ivar1;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @property (retain) NSObject *ivar2;
 @property (retain) NSObject *ivar3;
 @property (retain) NSObject *ivar4;
@@ -591,9 +537,6 @@ void ReleaseMe(id arg);
 
 @interface SuperClassOfClassWithInlinedSuperDealloc : NSObject
 @property (retain) NSObject *propInSuper;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation SuperClassOfClassWithInlinedSuperDealloc
@@ -606,9 +549,6 @@ void ReleaseMe(id arg);
 
 @interface ClassWithInlinedSuperDealloc : SuperClassOfClassWithInlinedSuperDealloc
 @property (retain) NSObject *propInSub;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation ClassWithInlinedSuperDealloc
@@ -666,9 +606,6 @@ void ReleaseMe(id arg);
 
 @interface SuperClassOfClassThatEscapesBeforeInliningSuper : NSObject
 @property (retain) NSObject *propInSuper;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation SuperClassOfClassThatEscapesBeforeInliningSuper
@@ -858,9 +795,6 @@ __attribute__((objc_root_class))
 
 @property(retain) NSObject *inputIvar;
 @property(retain) NSObject *nonInputIvar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @property(retain) NSObject *inputAutoSynthesizedIvar;
 @property(retain) NSObject *inputExplicitlySynthesizedToNonPrefixedIvar;
 @property(retain) NSObject *nonPrefixedPropertyBackedByExplicitlySynthesizedPrefixedIvar;
@@ -870,9 +804,6 @@ __attribute__((objc_root_class))
 @implementation ImmediateSubCIFilter
 @synthesize inputIvar = inputIvar;
 @synthesize nonInputIvar = nonInputIvar;
-#if NON_ARC
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 @synthesize inputExplicitlySynthesizedToNonPrefixedIvar = notPrefixedButBackingPrefixedProperty;
 @synthesize nonPrefixedPropertyBackedByExplicitlySynthesizedPrefixedIvar = inputPrefixedButBackingNonPrefixedProperty;
 
@@ -911,9 +842,6 @@ __attribute__((objc_root_class))
 }
 
 @property(retain) NSObject *inputIvar;
-#if NON_ARC
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation OverreleasingCIFilter
@@ -950,17 +878,11 @@ __attribute__((objc_root_class))
 }
 
 @property (readonly, retain) NSObject *ivarForOutlet;
-#if NON_ARC && !MACOS
-// expected-note at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation ClassWithRetainPropWithIBOutletIvarButNoSetter
 
 @synthesize ivarForOutlet;
-#if NON_ARC && !MACOS
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 - (void)dealloc {
 
 #if NON_ARC
@@ -987,17 +909,11 @@ __attribute__((objc_root_class))
 // 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 at -2 {{Property is declared here}}
-#endif
 @end
 
 @implementation ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite
 
 @synthesize ivarForOutlet;
-#if NON_ARC
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 - (void)dealloc {
 
 #if NON_ARC

Modified: cfe/trunk/test/Analysis/PR2978.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR2978.m?rev=284317&r1=284316&r2=284317&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/PR2978.m (original)
+++ cfe/trunk/test/Analysis/PR2978.m Sat Oct 15 19:30:08 2016
@@ -29,22 +29,22 @@
   id _nonPropertyIvar;
 }
 @property(retain) id X;
- at property(retain) id Y; // expected-note{{Property is declared here}}
- at property(assign) id Z; // expected-note{{Property is declared here}}
+ at property(retain) id Y;
+ at property(assign) id Z;
 @property(assign) id K;
 @property(weak) id L;
 @property(readonly) id N;
 @property(retain) id M;
 @property(weak) id P;
- at property(weak) id Q; // expected-note{{Property is declared here}}
+ at property(weak) id Q;
 @property(retain) id R;
- at property(weak, readonly) id S; // expected-note{{Property is declared here}}
+ at property(weak, readonly) id S;
 
 @property(assign, readonly) id T; // Shadowed in class extension
 @property(assign) id U;
 
 @property(retain) id V;
- at property(retain) id W; // expected-note{{Property is declared here}}
+ at property(retain) id W;
 -(id) O;
 -(void) setO: (id) arg;
 @end
@@ -56,16 +56,16 @@
 
 @implementation MyClass
 @synthesize X = _X;
- at synthesize Y = _Y; // expected-note{{Property is synthesized here}}
- at synthesize Z = _Z; // expected-note{{Property is synthesized here}}
+ at synthesize Y = _Y;
+ at synthesize Z = _Z;
 @synthesize K = _K;
 @synthesize L = _L;
 @synthesize N = _N;
 @synthesize M = _M;
- at synthesize Q = _Q; // expected-note{{Property is synthesized here}}
+ at synthesize Q = _Q;
 @synthesize R = _R;
 @synthesize V = _V;
- at synthesize W = _W; // expected-note{{Property is synthesized here}}
+ at synthesize W = _W;
 
 -(id) O{ return 0; }
 -(void) setO:(id)arg { }

Modified: cfe/trunk/test/Analysis/properties.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/properties.m?rev=284317&r1=284316&r2=284317&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/properties.m (original)
+++ cfe/trunk/test/Analysis/properties.m Sat Oct 15 19:30:08 2016
@@ -134,17 +134,11 @@ NSNumber* numberFromMyNumberProperty(MyN
   NSString *_name;
 }
 @property (retain) NSString * name;
-#if !__has_feature(objc_arc)
-// expected-note at -2 {{Property is declared here}}
-#endif
 @property (assign) id friend;
 @end
 
 @implementation Person
 @synthesize name = _name;
-#if !__has_feature(objc_arc)
-// expected-note at -2 {{Property is synthesized here}}
-#endif
 
 -(void)dealloc {
 #if !__has_feature(objc_arc)




More information about the cfe-commits mailing list