aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFRefCount.cpp
AgeCommit message (Collapse)Author
2009-02-23'[NSAutoreleasePool addObject:]' has an 'autorelease' effect, not a ↵Ted Kremenek
DoNothing effect. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65301 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-22Fix regression in naming convention derivation: a method only follows the ↵Ted Kremenek
copy 'rule' if it doesn't already start with 'init', etc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65269 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21Use llvm::StringsEqualNoCase instead of strncasecmp.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65237 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21Fix build on windows.Cedric Venet
Should clang have a config.h or should we use the config.h of llvm or using the preprocessor is OK? I did a quick fix here, but having a guideline on how to handle non portable function would be great (or ask ted to stop breaking the windows build :)). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65233 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21Improved naming convention heuristics in the retain/release checker to betterTed Kremenek
handle method names that contain 'new', 'copy', etc., but those words might be the substring of larger words such as 'newsgroup' and 'photocopy' that do not indicate the allocation of objects. This should address the issues discussed in <rdar://problem/6552389>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65224 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-20Fix crash from <rdar://problem/6562655>: 'init' method only return a ↵Ted Kremenek
receiver alias if the return type is a location. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65084 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19retain/release checker: Generate an intermediate simulation node for "leak"Ted Kremenek
transitions and then generate a subsequent node that removes the dead symbol bindings. This should drastically improve caching in the simulation graph when retain-counted objects are being tracked. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65082 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19retain/release checker: Fix crasher when the leak site is the same ↵Ted Kremenek
expression that allocates an object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65047 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18retain/release checker: Place the leak diagnostic after the last statement thatTed Kremenek
references the tracked object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64980 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18Remove unused variable.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64974 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18Remove logic for computing 'display hint'.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64973 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18More fun with retain checker diagnostics:Ted Kremenek
- Fix some grammar. - Fix a bug where a "reference count incremented" diagnostic would not be shown if the previous typestate was "Released" (only happens in GC mode). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64971 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18Fix diagnostics bugs when computing ranges for the retain/release checker.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64962 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18retain/release checker: We now emit fancy diagnostics telling users about theTed Kremenek
semantics of CFMakeCollectable and friends. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64956 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18retain/release checker: Distinguish in the function summaries betweenTed Kremenek
retain/releases performed via [... release] and CFRetain(). The former are no-ops in GC. The checker already handled this, but now we emit nice diagnostics to the user telling them that these are no-ops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64937 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18Hooked up the necessary machinery to allow the retain/release checker referenceTed Kremenek
back to the summary used when evaluating the statement associated with a simulation node. This is now being used to help improve the checker's diagnostics. To get things started, the checker now emits a path diagnostic indicating that 'autorelease' is a no-op in GC mode. Some of these changes are exposing further grossness in the interface between BugReporter and the ExplodedGraph::Trim facilities. These really need to be cleaned up one day. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64881 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18retain/release checker: Record the summary used to generate a given node.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64876 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14Added GRStateManager::scanReachableSymbols(), a method which scans the reachableTed Kremenek
symbols from an SVal. - Fixed a bug in EnvironmentManager::RemoveDeadBindings() where it did not mark live all the symbols reachable from a live block-level expression. - Fixed a bug in the retain/release checker where it did not stop tracking symbols that 'escaped' via compound literals being assigned to something the BasicStoreManager didn't reason about. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64534 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-14Static analyzer:Ted Kremenek
- Added a new 'node builder' class called GRStmtNodeBuilderRef (name may change). This is essentially a smart reference to a GRStmtNodeBuilder object that keeps track of the current context (predecessor node, GRExprEngine object, etc.) The idea is to gradually simplify the interface between GRExprEngine and GRTransferFuncs using this new builder (i.e., passing 1 argument instead of 5). It also handles some of the "auto-transition" for node creation, simplifying some of the logic in GRExprEngine itself. - Used GRStmtBuilderRef to replace GRTransferFuncs::EvalStore with GRTransferFuncs::EvalBind. The new EvalBind method will be used at any arbitrary places where a binding between a location and value takes place. Moreover, GRTransferFuncs no longer has the responsibility to request StoreManager to do the binding; this is now in GRExprEngine::EvalBind. All GRTransferFuncs::EvalBind does is checker-specific logic (which can be a no-op). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64525 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-12Several cleanups:Steve Naroff
- rename isObjCIdType/isObjCClassType -> isObjCIdStructType/isObjCClassStructType. The previous name didn't do what you would expect. - add back isObjCIdType/isObjCClassType to do what you would expect. Not currently used, however many of the isObjCIdStructType/isObjCClassStructType clients could be converted over time. - move static Sema function areComparableObjCInterfaces to ASTContext (renamed to areComparableObjCPointerTypes, since it now operates on pointer types). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64385 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07Fix null dereference.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64044 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07For retain/release leaks, have the BugReport description indicate the ↵Ted Kremenek
allocation site and initial bindings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64041 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07Determining the allocation site for a leak when constructing a ↵Ted Kremenek
CFRefLeakReport. This avoids repeated calls to GetAllocationSite when Profiling a CFRefLeakReport object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64036 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07Split logic for 'getEndPath()' for CFRefReport and CFRefLeakReport.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64034 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07Convert a use of 'std::ostringstream' to 'llvm::raw_string_ostream'.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64033 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05Add 'AppendValue' to the list of magic CF function names that cause a ↵Ted Kremenek
tracked object to escape. Fixes <rdar://problem/6560661>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63891 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05Remove a bunch of obscene double-buffering of BugReports in the retain/releaseTed Kremenek
checker. This was previously needed because BugReport objects were previously allocated on the stack and not owned by BugReporter. Now we can just issue them on the fly. This change was motivated because we were seeing some weird cases where some really long paths would get issued for bugs (particularly leaks) because of some double-caching. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63840 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05Fix regression: Leak (BugType) object should have 'isLeak()' return true.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63803 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-04Overhaul BugReporter interface and implementation. The new interface cleans upTed Kremenek
the ownership of BugTypes and BugReports. Now BugReports are owned by BugTypes, and BugTypes are owned by the BugReporter object. The major functionality change in this patch is that reports are not immediately emitted by a call to BugReporter::EmitWarning (now called EmitReport), but instead of queued up in report "equivalence classes". When BugReporter::FlushReports() is called, it emits one diagnostic per report equivalence class. This provides a nice cleanup with the caching of reports as well as enables the BugReporter engine to select the "best" path for reporting a path-sensitive bug based on all the locations in the ExplodedGraph that the same bug could occur. Along with this patch, Leaks are now coalesced into a common equivalence class by their allocation site, and the "summary" diagnostic for leaks now reports the allocation site as the location of the bug (this may later be augmented to also provide an example location where the leak occurs). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63796 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-29retain/release checker: When generating summaries for CF/CG functions, allow ↵Ted Kremenek
arguments to "escape" if they are passed to a function containing the terms "InsertValue", "SetValue", or "AddValue". This fixes <rdar://problem/6539791>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63341 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28Remove '#if 0' code.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63250 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28Remove method 'AddNE' from the public interface of ConstraintManager.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63249 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28retain/release checker: Always generate an "autorelease" summary for an ↵Ted Kremenek
"autorelease" message, and have the summary processing logic treat it as a no-op in GC mode. This change is motivated to encode more of the semantics in the summaries themselves for eventual better diagnostics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63241 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28retain/release checker: Improve diagnostics to indicate that CF objects are ↵Ted Kremenek
not automatically garbage collected. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63187 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28retain/release checker: Indicate whether a tracked object is a Core ↵Ted Kremenek
Foundation or Objective-C object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63186 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28retain/release checker: More diagnostic refactoring.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63184 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28retain/release checker: Embed an "object type" into the RetEffect/RetVal ↵Ted Kremenek
objects to help distinguish between Objective-C and Core Foundation objects (for better diagnostics). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63183 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28retain/release checker: More cleanups (no real functionality change).Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28Fix diagnostic truncated by my last patch.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63180 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28retain/release checker: More diagnostic refactoring.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63179 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28retain/release checker: Output the name of the function that allocates an ↵Ted Kremenek
object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63178 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28Refactor some diagnostic code to use raw_string_ostream. No functionality ↵Ted Kremenek
change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63177 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28Remove '#if 0' code.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24More hacking on static analyzer diagnostics. When emitting summary ↵Ted Kremenek
diagnostics the code paths for diagnostics involving paths or single locations are now unified. This patch also constifies many arguments/methods that are touched by this logic, leading to a nice overall code cleanup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62903 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-21Static Analyzer: Replace LiveSymbols/DeadSymbols sets with a new object ↵Ted Kremenek
called "SymbolReaper". Right now it just consolidates the two and cleans up some client code, but shortly it will be used to enable "lazy computation" of live symbols for use with RegionStore. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62722 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16Fix PR 3337 [retain/release checker]: Handle FunctionDecl's declared using ↵Ted Kremenek
typedefs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62331 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16more SourceLocation lexicon change: instead of referring to theChris Lattner
"logical" location, refer to the "instantiation" location. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62316 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-12retain/release checker:Ted Kremenek
- Refactor a bunch of logic in the retain/release checker, making it more condense and easier to read. - Add support for "Create" methods in the DiskArbitration framework retain/release tests: - Rename CFDate.m to retain-release.m, and move test from CFString.c to retain-release.m - Add DiskArbitration framework tests cases. - Add/refine and few more retain/release GC test cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62106 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-07This commit reflects changes to the retain/release checker motivated by myTed Kremenek
recent discussions with Thomas Clement and Ken Ferry concerning the "fundamental rule" for Cocoa memory management (http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html). Here is the revised behavior of the checker concerning tracking retain/release counts for objects returned from message expressions involving instance methods: 1) Track the returned object if the return type of the message expression is id<..>, id, or a pointer to *any* object that subclasses NSObject. Such objects are assumed to have a retain count. Previously the checker only tracked objects when the receiver of the message expression was part of the standard Cocoa API (i.e., had class names prefixed with 'NS'). This should significantly expand the amount of checking performed. 2) Consider the object owned if the selector of the message expression contains "alloc", "new", or "copy". Previously we also considered "create", but this doesn't follow from the fundamental rule (discussions with the Cocoa folks confirms this). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61837 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18Fix regression when invalidating reference-counts for objects ↵Ted Kremenek
passed-by-reference to a function/method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61224 91177308-0d34-0410-b5e6-96231b3b80d8