summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] When checking Foundation method calls, match the selectors exactly.Jordan Rose2014-04-091-12/+4
| | | | | | | | | | This also includes some infrastructure to make it easier to build multi-argument selectors, rather than trying to use string matching on each piece. There's a bit more setup code, but less cost at runtime. PR18908 llvm-svn: 205827
* [analyzer] Don't track retain counts of objects directly accessed through ivars.Jordan Rose2014-03-251-22/+111
| | | | | | | | | | | | | | | | | | | | | A refinement of r198953 to handle cases where an object is accessed both through a property getter and through direct ivar access. An object accessed through a property should always be treated as +0, i.e. not owned by the caller. However, an object accessed through an ivar may be at +0 or at +1, depending on whether the ivar is a strong reference. Outside of ARC, we don't have that information, so we just don't track objects accessed through ivars. With this change, accessing an ivar directly will deliberately override the +0 provided by a getter, but only if the +0 hasn't participated in other retain counting yet. That isn't perfect, but it's already unusual for people to be mixing property access with direct ivar access. (The primary use case for this is in setters, init methods, and -dealloc.) Thanks to Ted for spotting a few mistakes in private review. <rdar://problem/16333368> llvm-svn: 204730
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-151-22/+22
| | | | | | class. llvm-svn: 203999
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-7/+7
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* [analyzer] Improved checker naming in CFG dump.Anton Yartsev2014-02-171-10/+8
| | | | | | This implements FIXME from Checker.cpp (FIXME: We want to return the package + name of the checker here.) and replaces hardcoded checker names with the new ones obtained via getCheckName().getName(). llvm-svn: 201525
* Expose the name of the checker producing each diagnostic message.Alexander Kornienko2014-02-111-27/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-6/+6
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-1/+1
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* [analyzer] BlockCall shouldn't really be an AnyFunctionCall.Jordan Rose2014-01-151-2/+2
| | | | | | | | | | | | | | Per discussion with Anna a /long/ time ago, it was way too easy to misuse BlockCall: because it inherited from AnyFunctionCall (through SimpleCall), getDecl() was constrained to return a FunctionDecl, and you had to call getBlockDecl() instead. This goes against the whole point of CallEvent (to abstract over different ways to invoke bodies of code). Now, BlockCall just inherits directly from CallEvent. There's a bit of duplication in getting things out of the origin expression (which is still known to be a CallExpr), but nothing significant. llvm-svn: 199321
* [analyzer] Model getters of known-@synthesized Objective-C properties.Jordan Rose2014-01-101-0/+19
| | | | | | | | | | | | | | | | | | | | | ...by synthesizing their body to be "return self->_prop;", with an extra nudge to RetainCountChecker to still treat the value as +0 if we have no other information. This doesn't handle weak properties, but that's mostly correct anyway, since they can go to nil at any time. This also doesn't apply to properties whose implementations we can't see, since they may not be backed by an ivar at all. And finally, this doesn't handle properties of C++ class type, because we can't invoke the copy constructor. (Sema has actually done this work already, but the AST it synthesizes is one the analyzer doesn't quite handle -- it has an rvalue DeclRefExpr.) Modeling setters is likely to be more difficult (since it requires handling strong/copy), but not impossible. <rdar://problem/11956898> llvm-svn: 198953
* [analyzer] Remove unused ARCNotOwnedSymbol retain count return effect.Jordan Rose2014-01-071-3/+2
| | | | | | | | | | | | RetainCountChecker has to track returned object values to know if they are retained or not. Under ARC, even methods that return +1 are tracked by the system and should be treated as +0. However, this effect behaves exactly like NotOwned(ObjC), i.e. a generic Objective-C method that actually returns +0, so we don't need a special case for it. No functionality change. llvm-svn: 198709
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-3/+2
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* [analyzer] Don't track return value of NSNull +null for retain/release tracking.Ted Kremenek2014-01-031-0/+5
| | | | | | Fixes <rdar://problem/12858915>. llvm-svn: 198388
* Replacing calls to getAttr with calls to hasAttr for clarity. No functional ↵Aaron Ballman2013-12-191-14/+14
| | | | | | change intended -- this only replaces Boolean uses of getAttr. llvm-svn: 197648
* Forgot some references to misspelled enums.Benjamin Kramer2013-10-201-4/+4
| | | | llvm-svn: 193047
* Miscellaneous speling fixes.Benjamin Kramer2013-10-201-1/+1
| | | | llvm-svn: 193046
* [analyzer] RetainCountChecker: add support for CFAutorelease.Jordan Rose2013-10-071-8/+22
| | | | | | <rdar://problems/13710586&13710643> llvm-svn: 192113
* [analyzer] Stop tracking the objects with attribute cleanup in the ↵Anna Zaks2013-09-171-0/+10
| | | | | | | | 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
* Get rid of unused isPodLike definition.Eli Friedman2013-09-111-2/+0
| | | | llvm-svn: 190463
* Use the number of parameters in the actual method or function to determine ↵Ted Kremenek2013-08-161-7/+1
| | | | | | the CallEffects size. llvm-svn: 188587
* RetainCountChecker: Replace some loops with std:: algorithms.Benjamin Kramer2013-08-161-17/+5
| | | | llvm-svn: 188581
* Revert r188574. Turns out it isn't needed.Ted Kremenek2013-08-161-1/+0
| | | | llvm-svn: 188578
* Need summary info. about arguments toFariborz Jahanian2013-08-161-0/+1
| | | | | | CF functions coming from static analyzer API. llvm-svn: 188574
* [static analyzer] add a simple "CallEffects" API to query the retain count ↵Ted Kremenek2013-08-141-0/+44
| | | | | | | | | | | | | | semantics of a method. This is intended to be a simplified API, whose internals are deliberately less efficient for the purpose of a simplified interface, for use with clients that want to query the analyzer's heuristics for determining retain count semantics. There are no immediate clients, but it is intended to be used by the ObjC modernizer. llvm-svn: 188433
* [static analyzer] Factor out ArgEffect and RetEffect into public header file.Ted Kremenek2013-08-141-93/+14
| | | | | | | This is a WIP change to allow other clients to query the retain count heuristics of the static analyzer. llvm-svn: 188432
* [analyzer] Don't process autorelease counts in synthesized function bodies.Jordan Rose2013-08-011-1/+8
| | | | | | | | | | | | | | | We process autorelease counts when we exit functions, but if there's an issue in a synthesized body the report will get dropped. Just skip the processing for now and let it get handled when the caller gets around to processing autoreleases. (This is still suboptimal: objects autoreleased in the caller context should never be warned about when exiting a callee context, synthesized or not.) Second half of <rdar://problem/14611722> llvm-svn: 187625
* [analyzer] RetainCountChecker: don't track through xpc_connection_set_context.Jordan Rose2013-05-021-2/+4
| | | | | | | | | | | | 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] Fix a crash in RetainCountChecker - we should not rely on ↵Anna Zaks2013-04-251-1/+1
| | | | | | | | | | | CallEnter::getCallExpr to return non-NULL We get a CallEnter with a null expression, when processing a destructor. All other users of CallEnter::getCallExpr work fine with null as return value. (Addresses PR15832, Thanks to Jordan for reducing the test case!) llvm-svn: 180234
* [analyzer] Set the allocation site to be the uniqueing location for retain ↵Anna Zaks2013-04-231-2/+11
| | | | | | | | | | count checker leaks. The uniqueing location is the location which is part of the hash used to determine if two reports are the same. This is used by the CmpRuns.py script to compare two analyzer runs and determine which warnings are new. llvm-svn: 180166
* [analyzer] RetainCountChecker: Clean up path notes for autorelease.Jordan Rose2013-04-231-7/+9
| | | | | | | | No functionality change. <rdar://problem/13710586> llvm-svn: 180075
* [analyzer] Add experimental option "leak-diagnostics-reference-allocation".Ted Kremenek2013-04-161-10/+25
| | | | | | | | | | | | | | This is an opt-in tweak for leak diagnostics to reference the allocation site if the diagnostic consumer only wants a pithy amount of information, and not the entire path. This is a strawman enhancement that I expect to see some experimentation with over the next week, and can go away if we don't want it. Currently it is only used by RetainCountChecker, but could be used by MallocChecker if and when we decide this should stay in. llvm-svn: 179634
* [analyzer] Address Jordan’s review of r179219Anna Zaks2013-04-101-1/+1
| | | | llvm-svn: 179235
* [analyzer] Address Jordan’s code review of r 179221Anna Zaks2013-04-101-13/+17
| | | | llvm-svn: 179234
* [analyzer] When reporting a leak in RetainCount checker due to an early exit ↵Anna Zaks2013-04-101-14/+63
| | | | | | | | | from init, step into init. The heuristic here (proposed by Jordan) is that, usually, if a leak is due to an early exit from init, the allocation site will be a call to alloc. Note that in other cases init resets self to [super init], which becomes the allocation site of the object. llvm-svn: 179221
* [analyzer] Cleanup leak warnings: do not print the names of variables from ↵Anna Zaks2013-04-101-1/+8
| | | | | | other functions. llvm-svn: 179219
* [analyzer] RetainCountChecker: refactor annotation handling.Jordan Rose2013-04-041-63/+41
| | | | | | | | | ...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
* Use early return in printing logic. Minor cleanup.Ted Kremenek2013-03-281-2/+4
| | | | llvm-svn: 178264
* [analyzer] Don't let cf_audited_transfer override CFRetain semantics.Jordan Rose2013-03-041-6/+6
| | | | | | | | | | We weren't treating a cf_audited_transfer CFRetain as returning +1 because its name doesn't contain "Create" or "Copy". Oops! Fortunately, the standard definitions of these functions are not marked audited. <rdar://problem/13339601> llvm-svn: 176463
* Add back implicitly dropped const.David Blaikie2013-02-211-1/+1
| | | | | | | (found due to incoming improvements to llvm::cast machinery that will error on this sort of mistake) llvm-svn: 175817
* Replace ProgramPoint llvm::cast support to be well-defined.David Blaikie2013-02-211-7/+7
| | | | | | See r175462 for another example/more details. llvm-svn: 175812
* Include llvm::Optional in clang/Basic/LLVM.hDavid Blaikie2013-02-201-2/+1
| | | | | | Post-commit CR feedback from Jordan Rose regarding r175594. llvm-svn: 175679
* Replace SVal llvm::cast support to be well-defined.David Blaikie2013-02-201-1/+2
| | | | | | See r175462 for another example/more details. llvm-svn: 175594
* [analyzer]RetainCount: Fix an autorelease related false positive.Anna Zaks2013-01-311-1/+1
| | | | | | | 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-14/+2
| | | | | | | | | | | | | 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] Refactor: parameter rename.Anna Zaks2013-01-161-1/+1
| | | | llvm-svn: 172595
* [analyzer] -drain is not an alias for -release.Jordan Rose2013-01-141-4/+0
| | | | | | | | | | | 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
* [analyzer] Rename callback EndPath -> EndFunctionAnna Zaks2013-01-031-3/+3
| | | | | | | This better reflects when callback is called and what the checkers are relying on. (Both names meant the same pre-IPA.) llvm-svn: 171432
* [analyzer] Address Jordan's nitpicks as per code review of r170625.Anna Zaks2012-12-211-1/+1
| | | | llvm-svn: 170832
* Update RetainCountChecker to understand attribute ns_returns_autoreleased.Ted Kremenek2012-12-201-4/+6
| | | | | | Fixes <rdar://problem/12887356>. llvm-svn: 170724
* [analyzer] Add the pointer escaped callback.Anna Zaks2012-12-201-4/+5
| | | | | | | | | | Instead of using several callbacks to identify the pointer escape event, checkers now can register for the checkPointerEscape. Converted the Malloc checker to use the new callback. SimpleStreamChecker will be converted next. llvm-svn: 170625
OpenPOWER on IntegriCloud