summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [analyzer] Simplify RetainCountChecker's handling of dead symbols.Jordan Rose2012-12-061-29/+24
| | | | | | | | | Previously we made three passes over the set of dead symbols, and removed them from the state /twice/. Now we combine the autorelease pass and the symbol death pass, and only have to remove the bindings for the symbols that leaked. llvm-svn: 169527
* Only provide explicit getCapturedRegion() and getOriginalRegion() from ↵Ted Kremenek2012-12-061-1/+1
| | | | | | | | referenced_vars_iterator. This is a nice conceptual cleanup. llvm-svn: 169480
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-2/+2
| | | | | | | | | | | | | 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-4/+5
| | | | | | | | | 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
* [analyzer] add LocationContext::inTopFrame() helper.Anna Zaks2012-11-031-7/+1
| | | | llvm-svn: 167351
* [analyzer] Add some convenience accessors to CallEvent, and use them.Jordan Rose2012-11-021-5/+3
| | | | | | | | These are CallEvent-equivalents of helpers already accessible in CheckerContext, as part of making it easier for new checkers to be written using CallEvent rather than raw CallExprs. llvm-svn: 167338
* [analyzer] Use nice macros for the common ProgramStateTraits (map, set, list).Jordan Rose2012-11-021-24/+11
| | | | | | | | | Also, move the REGISTER_*_WITH_PROGRAMSTATE macros to ProgramStateTrait.h. This doesn't get rid of /all/ explicit uses of ProgramStatePartialTrait, but it does get a lot of them. llvm-svn: 167276
* [analyzer] Rename 'EmitReport' to 'emitReport'.Jordan Rose2012-11-021-5/+5
| | | | | | No functionality change. llvm-svn: 167275
* [analyzer] Rename ConditionTruthVal::isTrue to isConstrainedTrue.Jordan Rose2012-11-011-1/+3
| | | | | | | | (and the same for isFalse) No functionality change. llvm-svn: 167186
* Move assertion to not crash tests.Ted Kremenek2012-10-121-2/+1
| | | | llvm-svn: 165842
* Silence null dereference warnings by documenting context-specificTed Kremenek2012-10-121-0/+3
| | | | | | invariants using assertions. llvm-svn: 165840
* Remove ProgramState::getSymVal(). It was being misused by Checkers,Ted Kremenek2012-09-071-3/+2
| | | | | | | | | | | | | | | | | | | | with at least one subtle bug in MacOSXKeyChainAPIChecker where the calling the method was a substitute for assuming a symbolic value was null (which is not the case). We still keep ConstraintManager::getSymVal(), but we use that as an optimization in SValBuilder and ProgramState::getSVal() to constant-fold SVals. This is only if the ConstraintManager can provide us with that information, which is no longer a requirement. As part of this, introduce a default implementation of ConstraintManager::getSymVal() which returns null. For Checkers, introduce ConstraintManager::isNull(), which queries the state to see if the symbolic value is constrained to be a null value. It does this without assuming it has been implicitly constant folded. llvm-svn: 163428
* Teach RetainCountChecker that CFPlugInInstanceCreate does notTed Kremenek2012-09-061-0/+2
| | | | | | | | return a CF object at all. Fixes <rdar://problem/9566345> llvm-svn: 163362
* Refine diagnostics for leaks reported when returning an objectTed Kremenek2012-09-061-14/+22
| | | | | | | | via function/method with [CF,NS]_RETURNS_NOT_RETAINED. Fixes <rdar://problem/11379000>. llvm-svn: 163355
* [analyzer] Future-proofing r163012 (nameless functions and RetainCountChecker)Jordan Rose2012-09-011-4/+4
| | | | | | | | | Any future exceptions need to go INSIDE the test that checks if the IdentifierInfo is non-null! No functionality change. Thanks for the review, Ted. llvm-svn: 163067
* [analyzer] RetainCountChecker: don't assume all functions have names.Jordan Rose2012-08-311-2/+3
| | | | | | | | | | | | | | | Fixes a hard-to-reach crash when calling a non-member overloaded operator with arguments that may be callbacks. Future-proofing: don't make the same assumption in MallocSizeofChecker. Aside from possibly respecting attributes in the future, it might be possible to call 'malloc' through a function pointer. I audited all other uses of FunctionDecl::getIdentifier() in the analyzer; they all now correctly test to see if the identifier is present before using it. llvm-svn: 163012
* Teach RetainCountChecker about 'pragma clang arc_cf_code_audited'.Ted Kremenek2012-08-301-0/+5
| | | | llvm-svn: 162934
* [analyzer] Stop tracking symbols based on a retain count summary ofAnna Zaks2012-08-291-27/+101
| | | | | | | | | | | | inlined function. This resolves retain count checker false positives that are caused by inlining ObjC and other methods. Essentially, if we are passing an object to a method with "delegate" in the selector or a function pointer as another argument, we should stop tracking the other parameters/return value as far as the retain count checker is concerned. llvm-svn: 162876
* [analyzer] Remove unnecessary code.Anna Zaks2012-08-241-16/+0
| | | | | | | | This code has been added a while ago and removing it does not trigger any test failures. The false positives it was trying to suppress are probably handled by other logic (ex: special handling of delegates). llvm-svn: 162529
* [analyzer] Make analyzer less aggressive when dealing with [self init].Anna Zaks2012-08-241-0/+29
| | | | | | | | | | | | | | With inlining, retain count checker starts tracking 'self' through the init methods. The analyser results were too noisy if the developer did not follow 'self = [super init]' pattern (which is common especially in older code bases) - we reported self init anti-pattern AND possible use-after-free. This patch teaches the retain count checker to assume that [super init] does not fail when it's not consumed by another expression. This silences the retain count warning that warns about possibility of use-after-free when init fails, while preserving all the other checking on 'self'. llvm-svn: 162508
* Rename 'currentX' to 'currX' throughout analyzer and libAnalysis.Ted Kremenek2012-08-221-4/+2
| | | | | | | | | Also rename 'getCurrentBlockCounter()' to 'blockCount()'. This ripples a bunch of code simplifications; mostly aesthetic, but makes the code a bit tighter. llvm-svn: 162349
* Rename 'getConjuredSymbol*' to 'conjureSymbol*'.Ted Kremenek2012-08-221-1/+1
| | | | | | | | | | No need to have the "get", the word "conjure" is a verb too! Getting a conjured symbol is the same as conjuring one up. This shortening is largely cosmetic, but just this simple changed cleaned up a handful of lines, making them less verbose. llvm-svn: 162348
* [analyzer] Replace boolean IsSink parameters with 'generateSink' methods.Jordan Rose2012-08-201-1/+1
| | | | | | | | | | | Generating a sink is significantly different behavior from generating a normal node, and a simple boolean parameter can be rather opaque. Per offline discussion with Anna, adding new generation methods is the clearest way to communicate intent. No functionality change. llvm-svn: 162215
* [analyzer] Remove obsolete GenericNodeBuilderRefCount from RetainCountChecker.Jordan Rose2012-08-181-39/+16
| | | | | | | | | | This was once an adapter class between callbacks that had CheckerContexts and those that don't, but for a while now it's essentially just been a wrapper around a ProgramPointTag. We can just pass the tag around instead. No functionality change. llvm-svn: 162155
* [analyzer] Remove other #if 0 from Retain Count checker.Anna Zaks2012-08-141-37/+1
| | | | | | These date back to 2009, 2011. llvm-svn: 161876
* [analyzer] Remove autorelease pools code from the Retain Count checker.Anna Zaks2012-08-141-113/+0
| | | | llvm-svn: 161875
* [analyzer] Fixup to r161821Anna Zaks2012-08-141-3/+1
| | | | llvm-svn: 161854
* [analyzer] Disable autorelease pool tracking.Anna Zaks2012-08-141-2/+21
| | | | | | | | | The autorelease pool has not been implemented completely: we were adding the autoreleased symbols to the state, but never looking at them. Until we have a complete implementation, remove the overhead and comment out the unused code. llvm-svn: 161821
* [analyzer] Refactor RetainReleaseChecker to go through a function callAnna Zaks2012-08-141-40/+53
| | | | | | | | | | | to set/get/remove the RefBinding. No functional change here. Having these setter and getter methods will make it much easier when replacing the underlining representation of RefBindings (I just went through the exercise). It makes the code more readable as well. llvm-svn: 161820
* [analyzer] Ignore OS X 10.8's annotations for NSMakeCollectable.Jordan Rose2012-08-061-1/+6
| | | | | | | | | | The frameworks correctly use the 'cf_consumed' and 'ns_returns_retained' attributes for NSMakeCollectable, but we can model the behavior under garbage collection more precisely than that. No functionality change. llvm-svn: 161349
* [analyzer] Only allow CallEvents to be created by CallEventManager.Jordan Rose2012-07-301-2/+5
| | | | | | | | | | This ensures that it is valid to reference-count any CallEvents, and we won't accidentally try to reclaim a CallEvent that lives on the stack. It also hides an ugly switch statement for handling CallExprs! There should be no functionality change here. llvm-svn: 160986
* [analyzer] Rename Calls.{h,cpp} to CallEvent.{h,cpp}. No functionality change.Jordan Rose2012-07-261-1/+1
| | | | llvm-svn: 160815
* Fix a typo (the the => the)Sylvestre Ledru2012-07-231-1/+1
| | | | llvm-svn: 160622
* [analyzer] Combine all ObjC message CallEvents into ObjCMethodCall.Jordan Rose2012-07-181-21/+15
| | | | | | | | | | | | As pointed out by Anna, we only differentiate between explicit message sends This also adds support for ObjCSubscriptExprs, which are basically the same as properties in many ways. We were already checking these, but not emitting nice messages for them. This depends on the llvm::PointerIntPair change in r160456. llvm-svn: 160461
* Remove trivial destructor from SVal.Benjamin Kramer2012-07-181-1/+1
| | | | | | | | | | This enables the faster SmallVector in clang and also allows clang's unused variable warnings to be more effective. Fix the two instances that popped up. The RetainCountChecker change actually changes functionality, it would be nice if someone from the StaticAnalyzer folks could look at it. llvm-svn: 160444
* [analyzer] Make CallEnter, CallExitBegin, and CallExitEnd not be StmtPointsJordan Rose2012-07-101-1/+8
| | | | | | | These ProgramPoints are used in inlining calls, and not all calls have associated statements anymore. llvm-svn: 160021
* [analyzer] Add a CXXDestructorCall CallEvent.Jordan Rose2012-07-101-0/+1
| | | | | | | | While this work is still fairly tentative (destructors are still left out of the CFG by default), we now handle destructors in the same way as any other calls, instead of just automatically trying to inline them. llvm-svn: 160020
* [analyzer] Add new PreImplicitCall and PostImplicitCall ProgramPoints.Jordan Rose2012-07-101-1/+2
| | | | | | | | | | | | | | | | | These are currently unused, but are intended to be used in lieu of PreStmt and PostStmt when the call is implicit (e.g. an automatic object destructor). This also modifies the Data1 field of ProgramPoints to allow storing any pointer-sized value, as opposed to only aligned pointers. This is necessary to store SourceLocations. There is currently no BugReporter support for these; they should be skipped over in any diagnostic output. This commit also tags checkers that currently rely on function calls only occurring at StmtPoints. llvm-svn: 160019
* [analyzer] For now, don't inline non-static member overloaded operators.Jordan Rose2012-07-031-0/+1
| | | | | | | | | | | | | | Our current inlining support (specifically RegionStore::enterStackFrame) doesn't know that calls to overloaded operators may be calls to non-static member functions, and that in these cases the first argument should be treated as 'this'. This caused incorrect results and sometimes crashes. The long-term fix will be to rewrite RegionStore::enterStackFrame to use CallEvent and its subclasses, but for now we can just disable these problematic calls by classifying them under a new CallEvent, CXXMemberOperatorCall. llvm-svn: 159692
* [analyzer] Introduce CXXAllocatorCall to handle placement arg invalidation.Jordan Rose2012-07-021-0/+1
| | | | | | | This is NOT full-blown support for operator new, but removes some nasty duplicated code introduced in r158784. llvm-svn: 159608
* [analyzer] Convert existing checkers to use check::preCall and check::postCall.Jordan Rose2012-07-021-59/+9
| | | | llvm-svn: 159563
* [analyzer] Finish replacing ObjCMessage with ObjCMethodDecl and friends.Jordan Rose2012-07-021-10/+4
| | | | | | | | The preObjCMessage and postObjCMessage callbacks now take an ObjCMethodCall argument, which can represent an explicit message send (ObjCMessageSend) or an implicit message generated by a property access (ObjCPropertyAccess). llvm-svn: 159559
* [analyzer] Begin replacing ObjCMessage with ObjCMethodCall and friends.Jordan Rose2012-07-021-8/+9
| | | | | | | | | | | | Previously, the CallEvent subclass ObjCMessageInvocation was just a wrapper around the existing ObjCMessage abstraction (over message sends and property accesses). Now, we have abstract CallEvent ObjCMethodCall with subclasses ObjCMessageSend and ObjCPropertyAccess. In addition to removing yet another wrapper object, this should make it easy to add a ObjCSubscriptAccess call event soon. llvm-svn: 159558
* [analyzer] Convert RetainCountChecker to use CallEvent as much as possible.Jordan Rose2012-07-021-188/+237
| | | | | | | | | | | | | | | | | | | | | | | | | This ended allowing quite a bit of cleanup, and some minor changes. - CallEvent makes it easy to use hasNonZeroCallbackArg more aggressively, which we check in order to avoid false positives with callbacks that might release the object. - In order to support this for functions which consume their arguments, there are two new ArgEffects: DecRefAndStopTracking and DecRefMsgAndStopTracking. These act just like StopTracking, except that if the object only had a return count of +1 it's now considered released instead (so we still get use-after-free messages). - On the plus side, we no longer have to special-case +[NSObject performSelector:withObject:afterDelay:] and friends. - The use of IdentifierInfos in the method summary cache is now hidden; only the ObjCInterfaceDecl gets passed around most of the time. - Since we cache all "simple" summaries and check every function call, there is no real benefit to having NULL stand in for default summaries anymore. - Whitespace, unused methods, etc. Even more simplification to come when we get check::postCall and can unify all these other post* checks. llvm-svn: 159555
* [analyzer] Add a new abstraction over all types of calls: CallEventJordan Rose2012-07-021-2/+2
| | | | | | | | | | This is intended to replace CallOrObjCMessage, and is eventually intended to be used for anything that cares more about /what/ is being called than /how/ it's being called. For example, inlining destructors should be the same as inlining blocks, and checking __attribute__((nonnull)) should apply to the allocator calls generated by operator new. llvm-svn: 159554
* [analyzer] RetainCountChecker: remove unused SelfOwn ArgEffect kind.Jordan Rose2012-06-271-4/+1
| | | | llvm-svn: 159245
* [analyzer] RetainCount: don't track objects init'd with a delegateJordan Rose2012-06-151-4/+9
| | | | | | | | | We already didn't track objects that have delegates or callbacks or objects that are passed through void * "context pointers". It's a not-uncommon pattern to release the object in its callback, and so the leak message we give is not very helpful. llvm-svn: 158532
* Remove unused private member variables found by clang's new ↵Benjamin Kramer2012-06-061-32/+15
| | | | | | -Wunused-private-field. llvm-svn: 158086
* Replace some custom hash combines with the standard stuff from DenseMapInfo.Benjamin Kramer2012-05-271-8/+5
| | | | llvm-svn: 157531
* [analyzer] RetainCountChecker: track ObjC boxed expression objects.Jordy Rose2012-05-121-0/+45
| | | | llvm-svn: 156699
OpenPOWER on IntegriCloud