summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/retain-release.m
Commit message (Collapse)AuthorAgeFilesLines
* [Fix] Customize warnings for missing built-in typesJohannes Doerfert2019-07-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we detect a built-in declaration for which we cannot derive a type matching the pattern in the Builtins.def file, we currently emit a warning that the respective header is needed. However, this is not necessarily the behavior we want as it has no connection to the location of the declaration (which can actually be in the header in question). Instead, this warning is generated - if we could not build the type for the pattern on file (for some reason). Here we should make the reason explicit. The actual problem is otherwise circumvented as the warning is misleading, see [0] for an example. - if we could not build the type for the pattern because we do not have a type on record, possible since D55483, we should not emit any warning. See [1] for a legitimate problem. This patch address both cases. For the "setjmp" family a new warning is introduced and for built-ins without type on record, so far "pthread_create", we do not emit the warning anymore. Also see: PR40692 [0] https://lkml.org/lkml/2019/1/11/718 [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235583 Differential Revision: https://reviews.llvm.org/D58091 llvm-svn: 367387
* Reapply r362994 & co "[analyzer][tests] Add normalize_plist to replace ↵Hubert Tong2019-06-111-2/+2
| | | | | | | | | | | diff_plist" Following r363007, which reverted r362998, r362996, and r362994, reapply with adjustments for the CRLF differences encountered with Windows. Namely, the `-b` option of `diff` is employed, and the `grep` patterns have `$` replaced with `[[:space:]]*$`. llvm-svn: 363069
* Revert r362994 & co "[analyzer][tests] Add normalize_plist to replace ↵Reid Kleckner2019-06-101-2/+2
| | | | | | | | | | | diff_plist" Reverts r362998, r362996, and r362994 because the tests do not pass on Windows due to CRLF changes. Adding back `-w` to diff is not enough, the new grep substitution doesn't work on Windows, and fixing it is non-trivial. llvm-svn: 363007
* [analyzer][tests] Use normalize_plist in place of diff_plist (`cat` cases)Hubert Tong2019-06-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The `%diff_plist` lit substitution invokes `diff` with a non-portable `-I` option. The intended effect can be achieved by normalizing the inputs to `diff` beforehand. Such normalization can be done with `grep -Ev`, which is also used by other tests. This patch applies the change (adjusted for review comments) described in http://lists.llvm.org/pipermail/cfe-dev/2019-April/061904.html mechanically to the cases where the output file is piped to `%diff_plist` via `cat`. The changes were applied via a script, except that `clang/test/Analysis/NewDelete-path-notes.cpp` and `clang/test/Analysis/plist-macros-with-expansion.cpp` were each adjusted for the line-continuation on the relevant `RUN` step. Reviewers: NoQ, sfertile, xingxue, jasonliu, daltenty Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62950 llvm-svn: 362996
* [analyzer] [RetainCountChecker] Bugfix for tracking top-level parameters of ↵George Karpenkov2019-01-301-0/+13
| | | | | | | | Objective-C methods Differential Revision: https://reviews.llvm.org/D57433 llvm-svn: 352588
* [analyzer] [RetainCountChecker] Track input parameters to the top-level functionGeorge Karpenkov2019-01-291-0/+16
| | | | | | | | | | 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
* Emit !callback metadata and introduce the callback attributeJohannes Doerfert2019-01-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | With commit r351627, LLVM gained the ability to apply (existing) IPO optimizations on indirections through callbacks, or transitive calls. The general idea is that we use an abstraction to hide the middle man and represent the callback call in the context of the initial caller. It is described in more detail in the commit message of the LLVM patch r351627, the llvm::AbstractCallSite class description, and the language reference section on callback-metadata. This commit enables clang to emit !callback metadata that is understood by LLVM. It does so in three different cases: 1) For known broker functions declarations that are directly generated, e.g., __kmpc_fork_call for the OpenMP pragma parallel. 2) For known broker functions that are identified by their name and source location through the builtin detection, e.g., pthread_create from the POSIX thread API. 3) For user annotated functions that carry the "callback(callee, ...)" attribute. The attribute has to include the name, or index, of the callback callee and how the passed arguments can be identified (as many as the callback callee has). See the callback attribute documentation for detailed information. Differential Revision: https://reviews.llvm.org/D55483 llvm-svn: 351629
* [analyzer] [NFC] Fix the FIXME in testsGeorge Karpenkov2019-01-111-24032/+3
| | | | llvm-svn: 350946
* [analyzer] RetainCount: Suppress retain detection heuristic on some CM methods.Artem Dergachev2018-12-211-2/+28
| | | | | | | | | | | | If it ends with "Retain" like CFRetain and returns a CFTypeRef like CFRetain, then it is not necessarily a CFRetain. But it is indeed true that these two return something retained. Differential Revision: https://reviews.llvm.org/D55907 rdar://problem/39390714 llvm-svn: 349862
* [analyzer] Re-instate support for MakeCollectable is RetainCountCheckerGeorge Karpenkov2018-08-171-0/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D50872 llvm-svn: 340097
* [analyzer] Drop support for GC mode in RetainCountCheckerGeorge Karpenkov2018-08-171-14/+0
| | | | | | | | | | | | A lot of code in RetainCountChecker deals with GC mode. Given that GC mode is deprecated, Apple does not ship runtime for it, and modern compiler toolchain does not support it, it makes sense to remove the code dealing with it in order to aid understanding of RetainCountChecker. Differential Revision: https://reviews.llvm.org/D50747 llvm-svn: 340091
* [analyzer] Teach RetainCountChecker about CoreMedia APIsDevin Coughlin2017-11-251-0/+45
| | | | | | | | | | Teach the retain-count checker that CoreMedia reference types use CoreFoundation-style reference counting. This enables the checker to catch leaks and over releases of those types. rdar://problem/33599757 llvm-svn: 318979
* [Sema][ObjC] Warn about mismatches in attributes between overriding andAkira Hatanaka2017-09-201-3/+3
| | | | | | | | | | | | | overridden methods when compiling for non-ARC. Previously, clang would error out when compiling for ARC, but didn't print any diagnostics when compiling for non-ARC. This was pointed out in the patch review for attribute noescape: https://reviews.llvm.org/D32210 llvm-svn: 313717
* [analyzer] Add diagnostic text for generalized refcount annotations.Devin Coughlin2017-07-251-0/+11
| | | | | | | | | | | | | | | Add a 'Generalized' object kind to the retain-count checker and suitable generic diagnostic text for retain-count diagnostics involving those objects. For now the object kind is introduced in summaries by 'annotate' attributes. Once we have more experience with these annotations we will propose explicit attributes. Patch by Malhar Thakkar! Differential Revision: https://reviews.llvm.org/D35613 llvm-svn: 308990
* Use ARC parsing rules for ns_returns_retained in MRC so that code canJohn McCall2017-07-151-1/+1
| | | | | | | | be shared without warnings. Build AttributedTypes to leave breadcrumbs for tools like the static analyzer. Warn about attempting to use the attribute with incompatible return types. llvm-svn: 308092
* Reland 4: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-031-2/+2
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296895
* Revert "Reland 3: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-03-021-2/+2
| | | | | | | | multiple constraint managers" This reverts commit ea36f1406e1f36bf456c3f3929839b024128e468. llvm-svn: 296841
* Reland 3: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-021-2/+2
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296837
* Revert "Reland 2: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-03-021-2/+2
| | | | | | | | multiple constraint managers" This reverts commit f93343c099fff646a2314cc7f4925833708298b1. llvm-svn: 296836
* Reland 2: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-021-2/+2
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296835
* Revert "Reland: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-02-281-2/+2
| | | | | | | | multiple constraint managers" This reverts commit 1b28d0b10e1c8feccb971abb6ef7a18bee589830. llvm-svn: 296422
* Reland: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-02-281-2/+2
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296414
* Revert "[analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-02-271-2/+2
| | | | | | | | constraint managers" This reverts commit 8e7780b9e59ddaad1800baf533058d2c064d4787. llvm-svn: 296317
* [analyzer] NFC: Update test infrastructure to support multiple constraint ↵Dominic Chen2017-02-271-2/+2
| | | | | | | | | | | | | | managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296312
* [analyzer] Teach RetainCountChecker about VTCompressionSessionEncodeFrame()Devin Coughlin2016-11-111-0/+82
| | | | | | | | | | | | | | | The context argument passed to VideoToolbox's VTCompressionSessionEncodeFrame() function is ultimately passed to a callback supplied when creating the compression session and so may be freed by that callback. To suppress false positives in this case, teach the retain count checker to stop tracking that argument. This isn't suppressed by the usual callback context mechanism because the call to VTCompressionSessionEncodeFrame() doesn't include the callback itself. rdar://problem/27685213 llvm-svn: 286633
* [analyzer] Teach RetainCountChecker about CVFooRetainDevin Coughlin2016-08-111-0/+20
| | | | | | | | | | | | Change the retain count checker to treat CoreFoundation-style "CV"-prefixed reference types from CoreVideo similarly to CoreGraphics types. With this change, we treat CVFooRetain() on a CVFooRef type as a retain. CVFooRelease() APIs are annotated as consuming their parameter, so this change prevents false positives about incorrect decrements of reference counts. <rdar://problem/27116090> llvm-svn: 278382
* Replace __double_underscored type nullability qualifiers with ↵Douglas Gregor2015-06-241-1/+1
| | | | | | | | | | | | | | | | _Uppercase_underscored Addresses a conflict with glibc's __nonnull macro by renaming the type nullability qualifiers as follows: __nonnull -> _Nonnull __nullable -> _Nullable __null_unspecified -> _Null_unspecified This is the major part of rdar://problem/21530726, but does not yet provide the Darwin-specific behavior for the old names. llvm-svn: 240596
* CF_RETURNS_[NOT_]RETAINED on a param makes the inner pointer __nullable.Douglas Gregor2015-06-191-0/+7
| | | | | | | | | | | | | | That is, void cf2(CFTypeRef * __nullable p CF_RETURNS_NOT_RETAINED); is equivalent to void cf2(CFTypeRef __nullable * __nullable p CF_RETURNS_NOT_RETAINED); More rdar://problem/18742441 llvm-svn: 240186
* Allow the cf_returns_[not_]retained attributes to appear on out-parameters.Douglas Gregor2015-06-191-0/+27
| | | | | | | | | | | | | | | | Includes a simple static analyzer check and not much else, but we'll also be able to take advantage of this in Swift. This feature can be tested for using __has_feature(cf_returns_on_parameters). This commit also contains two fixes: - Look through non-typedef sugar when deciding whether something is a CF type. - When (cf|ns)_returns(_not)?_retained is applied to invalid properties, refer to "property" instead of "method" in the error message. rdar://problem/18742441 llvm-svn: 240185
* [analyzer] Check for NULL passed to CFAutorelease.Jordan Rose2014-06-211-15/+31
| | | | | | Patch by Sean McBride, tests adjusted by me. llvm-svn: 211453
* [analyzer] Don't track return value of NSNull +null for retain/release tracking.Ted Kremenek2014-01-031-5452/+5481
| | | | | | Fixes <rdar://problem/12858915>. llvm-svn: 198388
* Implemented delayed processing of 'unavailable' checking, just like with ↵Ted Kremenek2013-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 'deprecated'. Fixes <rdar://problem/15584219> and <rdar://problem/12241361>. This change looks large, but all it does is reuse and consolidate the delayed diagnostic logic for deprecation warnings with unavailability warnings. By doing so, it showed various inconsistencies between the diagnostics, which were close, but not consistent. It also revealed some missing "note:"'s in the deprecated diagnostics that were showing up in the unavailable diagnostics, etc. This change also changes the wording of the core deprecation diagnostics. Instead of saying "function has been explicitly marked deprecated" we now saw "'X' has been been explicitly marked deprecated". It turns out providing a bit more context is useful, and often we got the actual term wrong or it was not very precise (e.g., "function" instead of "destructor"). By just saying the name of the thing that is deprecated/deleted/unavailable we define this issue away. This diagnostic can likely be further wordsmithed to be shorter. llvm-svn: 197627
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-051-1/+1
| | | | llvm-svn: 196510
* [analyzer] RetainCountChecker: add support for CFAutorelease.Jordan Rose2013-10-071-0/+84
| | | | | | <rdar://problems/13710586&13710643> llvm-svn: 192113
* [analyzer] Stop tracking the objects with attribute cleanup in the ↵Anna Zaks2013-09-171-0/+14
| | | | | | | | RetainCountChecker. This suppresses false positive leaks. We stop tracking a value if it is assigned to a variable declared with a cleanup attribute. llvm-svn: 190835
* [analyzer] RetainCountChecker: don't track through xpc_connection_set_context.Jordan Rose2013-05-021-0/+20
| | | | | | | | | | | | It is unfortunate that we have to mark these exceptions in multiple places. This was already in CallEvent. I suppose it does let us be more precise about saying /which/ arguments have their retain counts invalidated -- the connection's is still valid even though the context object's isn't -- but we're not tracking the retain count of XPC objects anyway. <rdar://problem/13783514> llvm-svn: 180904
* [analyzer] RetainCountChecker: Clean up path notes for autorelease.Jordan Rose2013-04-231-31/+31
| | | | | | | | No functionality change. <rdar://problem/13710586> llvm-svn: 180075
* [analyzer] Cleanup leak warnings: do not print the names of variables from ↵Anna Zaks2013-04-101-1/+20
| | | | | | other functions. llvm-svn: 179219
* [analyzer] RetainCountChecker: refactor annotation handling.Jordan Rose2013-04-041-0/+15
| | | | | | | | | ...and add a new test case. I thought this was broken, but it isn't; refactoring and reformatting anyway so that I don't make the same mistake again. No functionality change. llvm-svn: 178799
* [analyzer]RetainCount: Fix an autorelease related false positive.Anna Zaks2013-01-311-0/+8
| | | | | | | The Cnt variable is adjusted (incremented) for simplification of checking logic. The increment should not be stored in the state. llvm-svn: 174104
* [analyzer] Don't track autorelease pools created by +new.Jordan Rose2013-01-311-2708/+3989
| | | | | | | | | | | | | This matches our behavior for autorelease pools created by +alloc. Some people like to create autorelease pools in one method and release them somewhere else. If you want safe autorelease pool semantics, use the new ARC-compatible syntax: @autoreleasepool { ... } <rdar://problem/13121353> llvm-svn: 174096
* [analyzer] -drain is not an alias for -release.Jordan Rose2013-01-141-0/+15
| | | | | | | | | | | This was previously added to support -[NSAutoreleasePool drain], which behaves like -release under non-GC and "please collect" under GC. We're not currently modeling the autorelease pool stack, though, so we can just take this out entirely. Fixes PR14927. llvm-svn: 172444
* Update RetainCountChecker to understand attribute ns_returns_autoreleased.Ted Kremenek2012-12-201-0/+6
| | | | | | Fixes <rdar://problem/12887356>. llvm-svn: 170724
* [analyzer] Report leaks at the closing brace of a function body.Jordan Rose2012-11-151-2/+2
| | | | | | | | | | | | | | | | | | | | This fixes a few cases where we'd emit path notes like this: +---+ 1| v p = malloc(len); ^ |2 +---+ In general this should make path notes more consistent and more correct, especially in cases where the leak happens on the false branch of an if that jumps directly to the end of the function. There are a couple places where the leak is reported farther away from the cause; these are usually cases where there are several levels of nested braces before the end of the function. This still matches our current behavior for when there /is/ a statement after all the braces, though. llvm-svn: 168070
* [analyzer] Check that the argument to CFMakeCollectable is non-NULL.Jordan Rose2012-11-071-5/+14
| | | | | | Patch by Sean McBride! llvm-svn: 167537
* Fix up more "$t"s in this test that should be "%t"s.Chandler Carruth2012-09-121-1/+1
| | | | llvm-svn: 163673
* Now that I have a test file to work with, disable the Filecheck part of this ↵Ted Kremenek2012-09-101-2/+2
| | | | | | test. llvm-svn: 163536
* Correctly 'cat' out test files.Ted Kremenek2012-09-101-2/+2
| | | | llvm-svn: 163534
* As a debugging aid to unbreak the buildbots, cat the plist files so I can ↵Ted Kremenek2012-09-101-2/+2
| | | | | | view them on different builders. llvm-svn: 163529
* Re-enable FileCheck testing of retain-release.m test, and forceTed Kremenek2012-09-101-3/+3
| | | | | | a C++ dialect. Let's see if this is the portability issue with this test. llvm-svn: 163524
OpenPOWER on IntegriCloud