summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] Make checkEndFunction() give access to the return statement.Reka Kovacs2018-07-161-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D49387 llvm-svn: 337215
* [NFC] fix trivial typos in comments and documentsHiroshi Inoue2018-01-261-1/+1
| | | | | | "in in" -> "in", "on on" -> "on" etc. llvm-svn: 323509
* [NFC] fix trivial typos in commentsHiroshi Inoue2018-01-221-1/+1
| | | | | | "the the" -> "the" llvm-svn: 323078
* Revert "[analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker""Devin Coughlin2016-10-161-35/+3
| | | | | | | | | | | | 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. llvm-svn: 284317
* [analyzer] DeallocChecker: Don't warn about directly-set IBOutlet ivars on macOSDevin Coughlin2016-10-121-0/+31
| | | | | | | | | | | | | | | | On macOS (but not iOS), if an ObjC property has no setter, the nib-loading code for an IBOutlet is documented as directly setting the backing ivar without retaining the value -- even if the property is 'retain'. This resulted in false positives from the DeallocChecker for code that did not release such ivars in -dealloc. To avoid these false positives, treat IBOutlet ivars that back a property without a setter as having an unknown release requirement in macOS. rdar://problem/28507353 llvm-svn: 284084
* [analyzer] Fix build error after r283660 - remove constexpr strings.Artem Dergachev2016-10-081-2/+8
| | | | llvm-svn: 283662
* [analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker"Artem Dergachev2016-10-081-3/+29
| | | | | | The parent commit (r283092) was reverted before and now finally landed. llvm-svn: 283660
* Revert "[analyzer] Add extra notes to ObjCDeallocChecker" as its depends on ↵Vitaly Buka2016-10-041-29/+3
| | | | | | | | reverted r283092 This reverts commit r283093. llvm-svn: 283181
* [analyzer] Add extra notes to ObjCDeallocCheckerArtem Dergachev2016-10-031-3/+29
| | | | | | | | | | The report is now highlighting instance variables and properties referenced by the warning message with the help of the extra notes feature recently introduced in r283092. Differential Revision: https://reviews.llvm.org/D24915 llvm-svn: 283093
* [analyzer] Fix misleading indentation in ObjCDeallocChecker. NFC.Devin Coughlin2016-07-281-1/+1
| | | | llvm-svn: 277009
* [analyzer] Implement a methond to discover origin region of a symbol.Artem Dergachev2016-07-131-9/+1
| | | | | | | | | | | | | This encourages checkers to make logical decisions depending on value of which region was the symbol under consideration introduced to denote. A similar technique is already used in a couple of checkers; they were modified to call the new method. Differential Revision: http://reviews.llvm.org/D22242 llvm-svn: 275290
* [analyzer] Teach ObjCDeallocChecker about XCTestCaseDevin Coughlin2016-06-221-9/+11
| | | | | | | | | | | Like with SenTestCase, subclasses of XCTestCase follow a "tear down" idiom to release instance variables and so typically do not release ivars in -dealloc. This commit applies the existing special casing for SenTestCase to XCTestCase as well. rdar://problem/25884696 llvm-svn: 273441
* [analyzer] Add CIFIlter modeling to DeallocChecker.Devin Coughlin2016-03-251-10/+56
| | | | | | | | | | | | | | | | | | | | The -dealloc method in CIFilter is highly unusual in that it will release instance variables belonging to its *subclasses* if the variable name starts with "input" or backs a property whose name starts with "input". Subclasses should not release these ivars in their own -dealloc method -- doing so could result in an over release. Before this commit, the DeallocChecker would warn about missing releases for such "input" properties -- which could cause users of the analyzer to add over releases to silence the warning. To avoid this, DeallocChecker now treats CIFilter "input-prefixed" ivars as MustNotReleaseDirectly and so will not require a release. Further, it will now warn when such an ivar is directly released in -dealloc. rdar://problem/25364901 llvm-svn: 264463
* [analyzer] Add diagnostic in ObjCDeallocChecker for use of -dealloc instead ↵Devin Coughlin2016-03-041-32/+92
| | | | | | | | | | | | | | | | | | of -release. In dealloc methods, the analyzer now warns when -dealloc is called directly on a synthesized retain/copy ivar instead of -release. This is intended to find mistakes of the form: - (void)dealloc { [_ivar dealloc]; // Mistaken call to -dealloc instead of -release [super dealloc]; } rdar://problem/16227989 llvm-svn: 262729
* [analyzer] ObjCDeallocChecker: Only check for nil-out when type is retainable.Devin Coughlin2016-03-031-1/+5
| | | | | | This fixes a crash when setting a property of struct type in -dealloc. llvm-svn: 262659
* [analyzer] Update CheckObjCDealloc diagnostic for missing -dealloc.Devin Coughlin2016-03-011-10/+18
| | | | | | | Update the diagnostic for classes missing -dealloc to mention an instance variable that needs to be released. llvm-svn: 262277
* [analyzer] Teach CheckObjCDealloc about Block_release().Devin Coughlin2016-02-291-10/+38
| | | | | | It now treats Block_release(b) as a release in addition to [b release]. llvm-svn: 262272
* [analyzer] Don't treat calls to system headers as escaping in CheckObjCDealloc.Devin Coughlin2016-02-291-21/+96
| | | | | | | | | | | | | | | | | | | This prevents false negatives when a -dealloc method, for example, removes itself as as an observer with [[NSNotificationCenter defaultCenter] removeObserver:self]. It is unlikely that passing 'self' to a system header method will release 'self''s instance variables, so this is unlikely to produce false positives. A challenge here is that while CheckObjCDealloc no longer treats these calls as escaping, the rest of the analyzer still does. In particular, this means that loads from the same instance variable before and after a call to a system header will result in different symbols being loaded by the region store. To account for this, the checker now treats different ivar symbols with the same instance and ivar decl as the same for the purpose of release checking and more eagerly removes a release requirement when an instance variable is assumed to be nil. This was not needed before because when an ivar escaped its release requirement was always removed -- now the requirement is not removed for calls to system headers. llvm-svn: 262261
* [analyzer] Prune some incorrect \param doc comment annotations.Devin Coughlin2016-02-261-12/+12
| | | | llvm-svn: 261970
* Checkers/CheckObjCDealloc.cpp: Prune "\param". [-Wdocumentation]NAKAMURA Takumi2016-02-261-1/+1
| | | | llvm-svn: 261963
* [analyzer] Reapply r261917 with a fix.Devin Coughlin2016-02-251-175/+752
| | | | | | | | This reapplies "[analyzer] Make ObjCDeallocChecker path sensitive." (r261917) with a fix for an error on some bots about specializing a template from another namespace. llvm-svn: 261929
* Revert "[analyzer] Make ObjCDeallocChecker path sensitive."Devin Coughlin2016-02-251-748/+175
| | | | | | This reverts commit r261917. It broke the bots. llvm-svn: 261921
* [analyzer] Make ObjCDeallocChecker path sensitive.Devin Coughlin2016-02-251-175/+748
| | | | | | | | | | | | | | Convert the ObjCDeallocChecker to be path sensitive. The primary motivation for this change is to prevent false positives when -dealloc calls helper invalidation methods to release instance variables, but it additionally improves precision when -dealloc contains control flow. It also reduces the need for pattern matching. The check for missing -dealloc methods remains AST-based. Part of rdar://problem/6927496 Differential Revision: http://reviews.llvm.org/D17511 llvm-svn: 261917
* [analyzer] Improve pattern matching in ObjCDealloc checker.Devin Coughlin2016-02-111-8/+17
| | | | | | | | Look through PseudoObjectExpr and OpaqueValueExprs when scanning for release-like operations. This commit also adds additional tests in anticipation of re-writing this as a path-sensitive checker. llvm-svn: 260608
* [analyzer] DeallocChecker: Don't warn on release of readonly assign property ↵Devin Coughlin2016-02-061-0/+6
| | | | | | | | | in dealloc. It is common for the ivars for read-only assign properties to always be stored retained, so don't warn for a release in dealloc for the ivar backing these properties. llvm-svn: 259998
* [analyzer] ObjCDeallocChecker: Only operate on classes with retained properties.Devin Coughlin2016-01-271-50/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the ObjC Dealloc Checker only checked classes with ivars, not retained properties, which caused three bugs: - False positive warnings about a missing -dealloc method in classes with only ivars. - Missing warnings about a missing -dealloc method on classes with only properties. - Missing warnings about an over-released or under-released ivar associated with a retained property in classes with only properties. The fix is to check only classes with at least one retained synthesized property. This also exposed a bug when reporting an over-released or under-released property that did not contain a synthesize statement. The checker tried to associate the warning with an @synthesize statement that did not exist, which caused an assertion failure in debug builds. The fix is to fall back to the @property statement in this case. A patch by David Kilzer! Part of rdar://problem/6927496 Differential Revision: http://reviews.llvm.org/D5023 llvm-svn: 258896
* [analyzer] Apply whitespace cleanups by Honggyu Kim.Ted Kremenek2015-09-081-2/+2
| | | | llvm-svn: 246978
* Rewrite users of Stmt::child_begin/end into for-range loops.Benjamin Kramer2015-07-031-2/+2
| | | | | | No functionality change intended. llvm-svn: 241355
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* [analyzer] Remove check covered by -Wobjc-missing-super-calls.Jordan Rose2014-08-221-39/+0
| | | | | | | | | The ObjCDealloc checker is currently disabled because it was too aggressive, but this is a good first step in getting it back to a useful state. Patch by David Kilzer! llvm-svn: 216272
* [C++11] Use 'nullptr'. StaticAnalyzer edition.Craig Topper2014-05-271-2/+2
| | | | llvm-svn: 209642
* [C++11] Replacing ObjCCategoryDecl iterators propimpl_begin() and ↵Aaron Ballman2014-03-141-4/+2
| | | | | | propimpl_end() with iterator_range property_impls(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203930
* [C++11] Replacing ObjCInterfaceDecl iterators ivar_begin() and ivar_end() ↵Aaron Ballman2014-03-131-7/+4
| | | | | | with iterator_range ivars(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203849
* [C++11] Replacing ObjCContainerDecl iterators instmeth_begin() and ↵Aaron Ballman2014-03-131-6/+4
| | | | | | instmeth_end() with iterator_range instance_methods(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203839
* Expose the name of the checker producing each diagnostic message.Alexander Kornienko2014-02-111-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In clang-tidy we'd like to know the name of the checker producing each diagnostic message. PathDiagnostic has BugType and Category fields, which are both arbitrary human-readable strings, but we need to know the exact name of the checker in the form that can be used in the CheckersControlList option to enable/disable the specific checker. This patch adds the CheckName field to the CheckerBase class, and sets it in the CheckerManager::registerChecker() method, which gets them from the CheckerRegistry. Checkers that implement multiple checks have to store the names of each check in the respective registerXXXChecker method. Reviewers: jordan_rose, krememek Reviewed By: jordan_rose CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2557 llvm-svn: 201186
* Replacing calls to getAttr with calls to hasAttr for clarity. No functional ↵Aaron Ballman2013-12-191-2/+2
| | | | | | change intended -- this only replaces Boolean uses of getAttr. llvm-svn: 197648
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-4/+4
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't ↵Benjamin Kramer2012-12-011-2/+3
| | | | | | | | | pull in all the generated Attr code. Required to pull some functions out of line, but this shouldn't have a perf impact. No functionality change. llvm-svn: 169092
* Remove redundant semicolons which are null statements.Dmitri Gribenko2012-09-101-1/+1
| | | | llvm-svn: 163546
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-2/+2
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-5/+5
| | | | | | | | | | | | | filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
* Require that all static analyzer issues have a category. As part of this ↵Ted Kremenek2012-04-051-6/+7
| | | | | | | | | | change, consolidate some commonly used category strings into global references (more of this can be done, I just did a few). Fixes <rdar://problem/11191537>. llvm-svn: 154121
* Include the "issue context" (e.g. function or method) where a static ↵Ted Kremenek2012-04-041-3/+3
| | | | | | | | analyzer issue occurred in the plist output. Fixes <rdar://problem/11004527> llvm-svn: 154030
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-2/+2
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Switch the ObjC*Decl raw_stream overloads to take a reference, for ↵Benjamin Kramer2012-02-071-2/+2
| | | | | | consistency with NamedDecls. llvm-svn: 149981
* Change operator<< for raw_ostream and NamedDecl to take a reference instead ↵Benjamin Kramer2011-10-141-3/+3
| | | | | | | | of a pointer. Passing a pointer was a bad idea as it collides with the overload for void*. llvm-svn: 141971
* [analyzer] Refactor PathDiagnosticLocation: Make ↵Anna Zaks2011-09-201-3/+9
| | | | | | | | PathDiagnosticLocation(SourceLocation...) private. Most of the effort here goes to making BugReport refer to a PathDiagnosticLocation instead of FullSourceLocation. (Another step closer to the goal of having Diagnostics which can recover from invalid SourceLocations.) llvm-svn: 140182
* Switch LangOptions over to a .def file that describes header of theDouglas Gregor2011-09-131-6/+6
| | | | | | | | | | language options. Use that .def file to declare the LangOptions class and initialize all of its members, eliminating a source of annoying initialization bugs. AST serialization changes are next up. llvm-svn: 139605
* Cleanup various declarations of 'Stmt*' to be 'Stmt *', etc. in libAnalyzer ↵Ted Kremenek2011-08-121-19/+19
| | | | | | and libStaticAnalyzer[*]. It was highly inconsistent, and very ugly to look at. llvm-svn: 137537
OpenPOWER on IntegriCloud