summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/osobject-retain-release.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] Specify the C++ standard in more tests.Artem Dergachev2019-10-191-1/+1
| | | | | | Makes life easier for downstream developers with different default standard. llvm-svn: 375308
* [analyzer] RetainCount: Add support for OSRequiredCast().Artem Dergachev2019-06-191-1/+20
| | | | | | | | | | | | | | It's a new API for custom RTTI in Apple IOKit/DriverKit framework that is similar to OSDynamicCast() that's already supported, but crashes instead of returning null (and therefore causing UB when the cast fails unexpectedly). Kind of like cast_or_null<> as opposed to dyn_cast_or_null<> in LLVM's RTTI. Historically, RetainCountChecker was responsible for modeling OSDynamicCast. This is simply an extension of the same functionality. Differential Revision: https://reviews.llvm.org/D63117 llvm-svn: 363891
* [analyzer] ConditionBRVisitor: MemberExpr supportCsaba Dabis2019-05-291-2/+6
| | | | | | | | | | | | | | | | | Summary: - Reviewers: NoQ, george.karpenkov Reviewed By: NoQ Subscribers: cfe-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D58206 llvm-svn: 362026
* [analyzer] ConditionBRVisitor: Enhance to write out more informationCsaba Dabis2019-05-291-1/+2
| | | | | | | | | | | | | | | | | | | | Summary: Add extra messages to the bug report to inform the user why the analyzer `Taking true/false branch`. Reviewers: NoQ, george.karpenkov Reviewed By: NoQ Subscribers: gerazo, gsd, dkrupp, whisperity, baloghadamsoftware, xazax.hun, eraman, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D53076 llvm-svn: 362020
* [analyzer] RetainCount: Fix os_returns_retained_on_zero with weird return types.Artem Dergachev2019-05-151-0/+13
| | | | | | | | | The checker was crashing when it was trying to assume a structure to be null or non-null so that to evaluate the effect of the annotation. Differential Revision: https://reviews.llvm.org/D61958 llvm-svn: 360790
* [analyzer] RetainCount: Add a suppression for "the Matching rule".Artem Dergachev2019-04-261-0/+23
| | | | | | | | | | | | | | | | In the OSObject universe there appears to be another slightly popular contract, apart from "create" and "get", which is "matching". It optionally consumes a "table" parameter and if a table is passed, it fills in the table and returns it at +0; otherwise, it creates a new table, fills it in and returns it at +1. For now suppress false positives by doing a conservative escape on all functions that end with "Matching", which is the naming convention that seems to be followed by all such methods. Differential Revision: https://reviews.llvm.org/D61161 llvm-svn: 359264
* [analyzer] [RetainCountChecker] Track input parameters to the top-level functionGeorge Karpenkov2019-01-291-3/+22
| | | | | | | | | | Track them for ISL/OS objects by default, and for NS/CF under a flag. rdar://47536377 Differential Revision: https://reviews.llvm.org/D57356 llvm-svn: 352534
* [analyzer] [RetainCountChecker] Support 'taggedRetain' and 'taggedRelease'George Karpenkov2019-01-291-4/+16
| | | | | | Differential Revision: https://reviews.llvm.org/D57211 llvm-svn: 352530
* [analyzer] Insert notes in RetainCountChecker where our dynamic cast ↵George Karpenkov2019-01-221-1/+2
| | | | | | | | | | modeling assumes 'null' output rdar://47397214 Differential Revision: https://reviews.llvm.org/D56952 llvm-svn: 351865
* [analyzer] Model another special-case kind of cast for OSObject ↵George Karpenkov2019-01-221-0/+3
| | | | | | | | RetainCountChecker Differential Revision: https://reviews.llvm.org/D56951 llvm-svn: 351864
* Revert "Fix failing MSan bots"George Karpenkov2019-01-181-39/+67
| | | | | | | | This reverts commit 2cedaaef383d8d6142046074ffebc2bb5a914778. Revert with a fix. llvm-svn: 351575
* Fix failing MSan botsVlad Tsyrklevich2019-01-181-67/+39
| | | | | | | Revert r351508-351514, this block of changes introduced a consistent MSan failure on the sanitizer bots. llvm-svn: 351528
* [analyzer] Introduce proper diagnostic for freeing unowned objectGeorge Karpenkov2019-01-181-0/+10
| | | | | | | | Insert a note when the object becomes not (exclusively) owned. Differential Revision: https://reviews.llvm.org/D56891 llvm-svn: 351514
* [analyzer] [RetainCountChecker] Produce a correct message when OSTypeAlloc ↵George Karpenkov2019-01-181-0/+7
| | | | | | | | is used Differential Revision: https://reviews.llvm.org/D56820 llvm-svn: 351509
* [analyzer] [RetainCountChecker] Smart pointer support.George Karpenkov2019-01-181-39/+50
| | | | | | | | rdar://47323216 Differential Revision: https://reviews.llvm.org/D56817 llvm-svn: 351508
* [analyzer] Another RetainCountChecker cleanupGeorge Karpenkov2019-01-161-0/+7
| | | | | | | | | This is not NFC strictly speaking, since it unifies CleanupAttr handling, so that out parameters now also understand it. Differential Revision: https://reviews.llvm.org/D56759 llvm-svn: 351394
* [analyzer] Support for OSObjects out parameters in RetainCountCheckerGeorge Karpenkov2019-01-111-1/+178
| | | | | | | | | rdar://46357478 rdar://47121327 Differential Revision: https://reviews.llvm.org/D56240 llvm-svn: 350982
* [analyzer] Quote the type of the leaked/problematic object in diagnostics ↵George Karpenkov2019-01-101-16/+16
| | | | | | | | for readability Differential Revision: https://reviews.llvm.org/D56344 llvm-svn: 350867
* [analyzer] Tests quickfix.George Karpenkov2018-12-211-1/+1
| | | | llvm-svn: 349943
* Revert "Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in ↵George Karpenkov2018-12-211-0/+8
| | | | | | | | | | RetainCountChecker on type mismatch even for inlined functions" This reverts commit b44b33f6e020a2c369da2b0c1d53cd52975f2526. Revert the revert with the fix. llvm-svn: 349939
* [analyzer] Correct the summary violation diagnostics for the retain count ↵George Karpenkov2018-12-211-2/+2
| | | | | | | | checker It should be in the past tense. llvm-svn: 349938
* Revert rL349876 from cfe/trunk: [analyzer] Perform escaping in ↵Simon Pilgrim2018-12-211-10/+0
| | | | | | | | | | | | | | RetainCountChecker on type mismatch even for inlined functions The fix done in D55465 did not previously apply when the function was inlined. rdar://46889541 Differential Revision: https://reviews.llvm.org/D55976 ........ Fixes broken buildbot: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/14764 llvm-svn: 349894
* [analyzer] Perform escaping in RetainCountChecker on type mismatch even for ↵George Karpenkov2018-12-211-0/+10
| | | | | | | | | | | | inlined functions The fix done in D55465 did not previously apply when the function was inlined. rdar://46889541 Differential Revision: https://reviews.llvm.org/D55976 llvm-svn: 349876
* [analyzer] Fix a bug in RetainCountDiagnostics while printing a note on ↵George Karpenkov2018-12-211-0/+16
| | | | | | | | | | | | mismatched summary in inlined functions Previously, we were not printing a note at all if at least one of the parameters was not annotated. rdar://46888422 Differential Revision: https://reviews.llvm.org/D55972 llvm-svn: 349875
* [analyzer] Fix unknown block calls to have zero parameters.Artem Dergachev2018-12-151-1/+10
| | | | | | | | | | | | Right now they report to have one parameter with null decl, because initializing an ArrayRef of pointers with a nullptr yields an ArrayRef to an array of one null pointer. Fixes a crash in the OSObject section of RetainCountChecker. Differential Revision: https://reviews.llvm.org/D55671 llvm-svn: 349229
* [analyzer] Display a diagnostics when an inlined function violates its ↵George Karpenkov2018-12-111-1/+27
| | | | | | | | | | | | | os_consumed summary This is currently a diagnostics, but might be upgraded to an error in the future, especially if we introduce os_return_on_success attributes. rdar://46359592 Differential Revision: https://reviews.llvm.org/D55530 llvm-svn: 348820
* [analyzer] Resolve another bug where the name of the leaked object was not ↵George Karpenkov2018-12-111-2/+2
| | | | | | | | printed properly Differential Revision: https://reviews.llvm.org/D55528 llvm-svn: 348819
* Stop tracking retain count of OSObject after escape to void * / other ↵George Karpenkov2018-12-081-0/+7
| | | | | | | | | | | | | | primitive types Escaping to void * / uint64_t / others non-OSObject * should stop tracking, as such functions can have heterogeneous semantics depending on context, and can not always be annotated. rdar://46439133 Differential Revision: https://reviews.llvm.org/D55465 llvm-svn: 348675
* [analyzer] Move out tracking retain count for OSObjects into a separate checkerGeorge Karpenkov2018-12-071-1/+1
| | | | | | | | | Allow enabling and disabling tracking of ObjC/CF objects separately from tracking of OS objects. Differential Revision: https://reviews.llvm.org/D55400 llvm-svn: 348638
* [analyzer] Rely on os_consumes_this attribute to signify that the method ↵George Karpenkov2018-12-061-0/+16
| | | | | | | | call consumes a reference for "this" Differential Revision: https://reviews.llvm.org/D55158 llvm-svn: 348533
* [analyzer] Fix an infinite recursion bug while checking parent methods in ↵George Karpenkov2018-12-061-0/+12
| | | | | | | | RetainCountChecker Differential Revision: https://reviews.llvm.org/D55351 llvm-svn: 348531
* [analyzer] Attribute for RetainCountChecker for OSObject should propagate ↵George Karpenkov2018-12-051-3/+35
| | | | | | | | | | with inheritance rdar://46388388 Differential Revision: https://reviews.llvm.org/D55154 llvm-svn: 348396
* Revert "Reverting r347949-r347951 because they broke the test bots."George Karpenkov2018-11-301-0/+34
| | | | | | | | This reverts commit 5bad6129c012fbf186eb055be49344e790448ecc. Hopefully fixing the issue which was breaking the bots. llvm-svn: 348030
* Reverting r347949-r347951 because they broke the test bots.Aaron Ballman2018-11-301-32/+0
| | | | | | http://lab.llvm.org:8011/builders/clang-cmake-armv8-lld/builds/440/steps/ninja%20check%202/logs/FAIL%3A%20Clang%3A%3Aosobject-retain-release.cpp llvm-svn: 348020
* [analyzer] Fixes after rebase.George Karpenkov2018-11-301-5/+5
| | | | llvm-svn: 347951
* [analyzer] RetainCountChecker for OSObject model the "free" callGeorge Karpenkov2018-11-301-0/+17
| | | | | | | | | The "free" call frees the object immediately, ignoring the reference count. Sadly, it is actually used in a few places, so we need to model it. Differential Revision: https://reviews.llvm.org/D55092 llvm-svn: 347950
* [analyzer] RetainCountChecker: recognize that OSObject can be created ↵George Karpenkov2018-11-301-0/+15
| | | | | | | | directly using an operator "new" Differential Revision: https://reviews.llvm.org/D55076 llvm-svn: 347949
* [analyzer] Switch retain count checker for OSObject to use OS_* attributesGeorge Karpenkov2018-11-301-3/+3
| | | | | | | | Instead of generalized reference counting annotations. Differential Revision: https://reviews.llvm.org/D55041 llvm-svn: 347948
* [analyzer] [NFC] Minor refactoring of RetainCountDiagnosticsGeorge Karpenkov2018-11-301-7/+11
| | | | | | | | | Move visitors to the implementation file, move a complicated logic into a function. Differential Revision: https://reviews.llvm.org/D55036 llvm-svn: 347946
* [analyzer] For OSObject, trust that functions starting with GetGeorge Karpenkov2018-11-301-0/+11
| | | | | | | | (uppercase) are also getters. Differential Revision: https://reviews.llvm.org/D55035 llvm-svn: 347945
* [analyzer] Print a fully qualified name for functions in RetainCountChecker ↵George Karpenkov2018-11-301-9/+14
| | | | | | | | | | | diagnostics Attempt to get a fully qualified name from AST if an SVal corresponding to the object is not available. Differential Revision: https://reviews.llvm.org/D55034 llvm-svn: 347944
* [analyzer] Add the type of the leaked object to the diagnostic messageGeorge Karpenkov2018-11-301-7/+11
| | | | | | | | | | | | If the object is a temporary, and there is no variable it binds to, let's at least print out the object name in order to help differentiate it from other temporaries. rdar://45175098 Differential Revision: https://reviews.llvm.org/D55033 llvm-svn: 347943
* [analyzer] Reference leaked object by name, even if it was created in an ↵George Karpenkov2018-11-301-2/+22
| | | | | | | | | | inlined function. rdar://45532181 Differential Revision: https://reviews.llvm.org/D54973 llvm-svn: 347942
* [analyzer] Re-add custom OSIterator rule for RetainCountCheckerGeorge Karpenkov2018-10-311-0/+10
| | | | | | | | Turns out the rule is quite ubiquitous. Revert of https://reviews.llvm.org/D53628 llvm-svn: 345747
* [analyzer] RetainCountChecker: for now, do not trust the summaries of ↵George Karpenkov2018-10-311-23/+39
| | | | | | | | | | | | | | | | inlined code Trusting summaries of inlined code would require a more thorough work, as the current approach was causing too many false positives, as the new example in test. The culprit lies in the fact that we currently escape all variables written into a field (but not passed off to unknown functions!), which can result in inconsistent behavior. rdar://45655344 Differential Revision: https://reviews.llvm.org/D53902 llvm-svn: 345746
* [analyzer] Enable retain count checking for OSObject by defaGeorge Karpenkov2018-10-311-1/+1
| | | | | | | | The FP rate seems to be good enough now. Differential Revision: https://reviews.llvm.org/D53849 llvm-svn: 345745
* [analyzer] [RetainCountChecker] Do not invalidate references passed to ↵George Karpenkov2018-10-251-0/+7
| | | | | | | | constructors and operators Differential Revision: https://reviews.llvm.org/D53660 llvm-svn: 345340
* [analyzer] Correct modelling of OSDynamicCast: eagerly state splitGeorge Karpenkov2018-10-251-1/+26
| | | | | | | | | | | | | | | | | | | | | Previously, OSDynamicCast was modeled as an identity. This is not correct: the output of OSDynamicCast may be zero even if the input was not zero (if the class is not of desired type), and thus the modeling led to false positives. Instead, we are doing eager state split: in one branch, the returned value is identical to the input parameter, and in the other branch, the returned value is zero. This patch required a substantial refactoring of canEval infrastructure, as now it can return different function summaries, and not just true/false. rdar://45497400 Differential Revision: https://reviews.llvm.org/D53624 llvm-svn: 345338
* [analyzer] Do not stop tracking CXX methods touching OSObject.George Karpenkov2018-10-231-5/+44
| | | | | | | | Trust generalized annotations for OSObject. Differential Revision: https://reviews.llvm.org/D53550 llvm-svn: 345100
* [analyzer] Trust summaries for OSObject::retain and OSObject::releaseGeorge Karpenkov2018-10-231-1/+1
| | | | | | | | Refactor the way in which summaries are consumed for safeMetaCast Differential Revision: https://reviews.llvm.org/D53549 llvm-svn: 345099
OpenPOWER on IntegriCloud