diff options
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp b/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp index f4d2e32cef111..00a912f27a8d4 100644 --- a/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp +++ b/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp @@ -28,7 +28,7 @@ // //===----------------------------------------------------------------------===// -#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h" #include "clang/AST/Attr.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" @@ -178,20 +178,12 @@ private: }; } // End anonymous namespace. -typedef llvm::ImmutableSet<SymbolRef> SymbolSet; /// Maps from the symbol for a class instance to the set of /// symbols remaining that must be released in -dealloc. +REGISTER_SET_FACTORY_WITH_PROGRAMSTATE(SymbolSet, SymbolRef) REGISTER_MAP_WITH_PROGRAMSTATE(UnreleasedIvarMap, SymbolRef, SymbolSet) -namespace clang { -namespace ento { -template<> struct ProgramStateTrait<SymbolSet> -: public ProgramStatePartialTrait<SymbolSet> { - static void *GDMIndex() { static int index = 0; return &index; } -}; -} -} /// An AST check that diagnose when the class requires a -dealloc method and /// is missing one. @@ -723,6 +715,10 @@ bool ObjCDeallocChecker::diagnoseExtraRelease(SymbolRef ReleasedValue, bool ObjCDeallocChecker::diagnoseMistakenDealloc(SymbolRef DeallocedValue, const ObjCMethodCall &M, CheckerContext &C) const { + // TODO: Apart from unknown/undefined receivers, this may happen when + // dealloc is called as a class method. Should we warn? + if (!DeallocedValue) + return false; // Find the property backing the instance variable that M // is dealloc'ing. @@ -761,15 +757,15 @@ ObjCDeallocChecker::ObjCDeallocChecker() MissingReleaseBugType.reset( new BugType(this, "Missing ivar release (leak)", - categories::MemoryCoreFoundationObjectiveC)); + categories::MemoryRefCount)); ExtraReleaseBugType.reset( new BugType(this, "Extra ivar release", - categories::MemoryCoreFoundationObjectiveC)); + categories::MemoryRefCount)); MistakenDeallocBugType.reset( new BugType(this, "Mistaken dealloc", - categories::MemoryCoreFoundationObjectiveC)); + categories::MemoryRefCount)); } void ObjCDeallocChecker::initIdentifierInfoAndSelectors( |