Граф коммитов

289 Коммитов

Автор SHA1 Сообщение Дата
Ted Kremenek a5770b9c0d Remove GetLeakNode. This isn't the right approach.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68502 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 05:07:44 +00:00
Ted Kremenek 0b3c9a9fe4 Eagerly compute the leak location when a leak occurs at the end of a path.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68496 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 04:54:20 +00:00
Ted Kremenek 933c42217f retain/release checker: When hunting for the leak location, don't walk the
ExplodedGraph backwards. That may inadvertently result in reverse control-flow
edges in the PathDiagostic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68477 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-07 00:12:43 +00:00
Ted Kremenek 9dab0ed04e Sentence-case bug type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68406 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-03 21:10:31 +00:00
Ted Kremenek 99d0269390 retain/release checker: don't track NSPanel until we have better reasoning about
the subtle ownership issues of such objects.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68397 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-03 19:02:51 +00:00
Ted Kremenek c2dcd89e4b Fix grammar.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68282 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 03:42:38 +00:00
Ted Kremenek 4188409d29 Title-case the names of bug types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68274 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-02 02:40:45 +00:00
Ted Kremenek 5fb5dfb664 - Changed PathDiagnosticPiece::getLocation() to return a PathDiagnosticLocation
instead of a FullSourceLoc. This resulted in a bunch of small edits in various
  clients.
- Updated BugReporter to include an alternate PathDiagnostic generation
  algorithm for PathDiagnosticClients desiring more control-flow pieces.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-01 06:13:56 +00:00
Ted Kremenek e0e4ebf6bf analyzer infrastructure: make a bunch of changes to symbolic expressions that
Zhongxing and I discussed by email.

Main changes:
- Removed SymIntConstraintVal and SymIntConstraint
- Added SymExpr as a parent class to SymbolData, SymSymExpr, SymIntExpr
- Added nonloc::SymExprVal to wrap SymExpr
- SymbolRef is now just a typedef of 'const SymbolData*'
- Bunch of minor code cleanups in how some methods were invoked (no functionality change)

This changes are part of a long-term plan to have full symbolic expression
trees. This will be useful for lazily evaluating complicated expressions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67731 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-26 03:35:11 +00:00
Ted Kremenek 7037ab8f15 retain/release checker: Tracking autorelease counts for objects. We're still not
completely there with accurately modeling autorelease pools.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67384 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-20 17:34:15 +00:00
Ted Kremenek 6199190333 Stub out some code for support for NSDeallocateObject. This is enabled yet until
we resolve the semantics of this function when GC is enabled.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67116 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-17 22:43:44 +00:00
Ted Kremenek f95e9fcffb retain/release checker: Add support for reasoning about -dealloc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67094 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-17 19:42:23 +00:00
Ted Kremenek 8be2a67620 Fix PR 3677 [retain checker]: custom 'allocWithZone' methods should be allowed
to return an owning pointer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66934 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-13 20:27:06 +00:00
Ted Kremenek d3ad531dd4 Remove '[naming convention]' from bug type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66739 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11 23:43:16 +00:00
Ted Kremenek 25d01badc5 retain/release checker: Allow allocations to fail by returning nil.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66487 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-09 22:46:49 +00:00
Ted Kremenek 1fbfd5b9b8 Create PathDiagnosticPiece subclasses PathDiagnosticEventPiece and
PathDiagnosticControlFlowPiece to distinguish (in the class hierarchy) between
events and control-flow diagnostic pieces. Clients must now use these directly
when constructing PathDiagnosticPieces.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66310 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-06 23:58:11 +00:00
Ted Kremenek bf0a4dd225 Minor tweak: Recognize 'CGCF' prefix in addition to 'CF' and 'CG'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66208 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 22:11:14 +00:00
Ted Kremenek be91224894 BasicStore:
- Store bindings using a MemRegion -> SVal binding instead of VarDecl -> SVal
  binding. This mirrors some of the idea of RegionStore, but is far simpler and
  not nearly as functional.  This leads to some code simplification and
  some potential for some minor precision hacks.
  
Along the way...
- constify the use of MemRegion* in a few places
- add operator<<(llvm::raw_ostream, const MemRegion*)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 16:31:07 +00:00
Ted Kremenek 452c31e663 Fix message title
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66110 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-05 00:12:45 +00:00
Ted Kremenek 3aa7ecd53f For now, do not track NSWindow objects and it's subclasses.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66107 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 23:30:42 +00:00
Ted Kremenek d104a09d30 Add prototype support for invalidating fields for structures passed-by-reference
to unknown functions. Most of this logic should be eventually moved to
RegionStore and be made lazy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66094 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 22:56:43 +00:00
Ted Kremenek 41168eac25 Added the notion of a "boundable region", which is a region that can have a direct binding in the StoreManager.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66005 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 02:43:08 +00:00
Ted Kremenek 3f4d5abe90 Use GetSValAsScalarOrLoc instead of GetSVal to prevent unintended structure or array "loads".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65983 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04 00:13:50 +00:00
Ted Kremenek 94c969804b Rework use of loc::SymbolVal in the retain/release checker to use the new method
SVal::getAsLocSymbol(). This simplifies the code and allows the retain/release
checker to (I believe) also correctly reason about location symbols wrapped in
SymbolicRegions.

Along the way I cleaned up SymbolRef a little, disallowing implicit casts to
'unsigned'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65972 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-03 22:06:47 +00:00
Ted Kremenek 0312c0e09c Rename AnonTypedRegion to TypedViewRegion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65764 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-01 05:44:08 +00:00
Douglas Gregor 72564e7327 Create a new TypeNodes.def file that enumerates all of the types,
giving them rough classifications (normal types, never-canonical
types, always-dependent types, abstract type representations) and
making it far easier to make sure that we've hit all of the cases when
decoding types. 

Switched some switch() statements on the type class over to using this
mechanism, and filtering out those things we don't care about. For
example, CodeGen should never see always-dependent or non-canonical
types, while debug info generation should never see always-dependent
types. More switch() statements on the type class need to be moved 
over to using this approach, so that we'll get warnings when we add a
new type then fail to account for it somewhere in the compiler.

As part of this, some types have been renamed:

  TypeOfExpr -> TypeOfExprType
  FunctionTypeProto -> FunctionProtoType
  FunctionTypeNoProto -> FunctionNoProtoType

There shouldn't be any functionality change...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65591 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 23:50:07 +00:00
Ted Kremenek e198116646 Refine some grammar in the retain/release diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65571 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-26 21:04:07 +00:00
Ted Kremenek 3579073233 Fix recently introduced switch case fallthrough bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65485 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-25 23:11:49 +00:00
Ted Kremenek 6c4becbab5 retain/release checker: Implement basic tracking of autorelease stack. Next thing is to wire up pools with their contents.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65425 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-25 02:54:57 +00:00
Ted Kremenek 6431a26956 Fix broken logic from my last commit. Branches only occur at basic blocks that end with terminators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65410 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 23:34:17 +00:00
Ted Kremenek 4094b34a60 Fix diagnostic regression where the leak diagnostic could appear earlier in the path than the branches taken.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65407 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 23:30:57 +00:00
Ted Kremenek 4d3957da69 retain/release checker:
- For autorelease pool tracking, keep information about the stack of pools
  separate from their contents. Also, keep track of the number of times an
  autorelease pool will send the "release" message to an object when the pool is
  destroyed.
- Update CFRefCount::Update to return a new state instead of a reference count
  binding. This will allow us to implement more complicated semantics with
  autorelease pools.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65384 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-24 19:15:11 +00:00
Ted Kremenek f9a8e2e1cf Add more boilerplate logic to more accurately reason about autorelease pools.
This doesn't change the current functionality, but better codifies the
autorelease pool stack itself.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65328 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 17:45:03 +00:00
Ted Kremenek 4634735e0a Fix 80 col. violations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65322 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 16:54:00 +00:00
Ted Kremenek 6ad315a4be Per Chris L.'s suggestion, use getAsFunctionType() instead of getDesguaredType(). Constify some pointers along the way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65321 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 16:51:39 +00:00
Ted Kremenek 89e202d6a4 retain/release checker: For now don't track the retain count of NSWindow objects (opt for false negatives).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65304 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 02:51:29 +00:00
Ted Kremenek 4e83501331 Remove typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65302 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 02:42:56 +00:00
Ted Kremenek 022a3c4e9e '[NSAutoreleasePool addObject:]' has an 'autorelease' effect, not a DoNothing effect.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65301 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-23 02:31:16 +00:00
Ted Kremenek 61d2e4a299 Fix regression in naming convention derivation: a method only follows the 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-22 07:32:24 +00:00
Ted Kremenek 39868cd436 Use llvm::StringsEqualNoCase instead of strncasecmp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65237 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-21 18:26:02 +00:00
Cedric Venet 61490e9a96 Fix build on windows.
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-21 17:14:49 +00:00
Ted Kremenek b80976c752 Improved naming convention heuristics in the retain/release checker to better
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-21 05:13:43 +00:00
Ted Kremenek c3cf7b27df Fix crash from <rdar://problem/6562655>: 'init' method only return a 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-20 00:05:35 +00:00
Ted Kremenek 33b6f6352d retain/release checker: Generate an intermediate simulation node for "leak"
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-19 23:47:02 +00:00
Ted Kremenek b1dbf158db retain/release checker: Fix crasher when the leak site is the same expression that allocates an object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65047 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-19 18:18:48 +00:00
Ted Kremenek d55979238d retain/release checker: Place the leak diagnostic after the last statement that
references the tracked object.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64980 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 23:28:26 +00:00
Ted Kremenek 81f14a0be0 Remove unused variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64974 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 22:59:38 +00:00
Ted Kremenek 572b2782ca Remove logic for computing 'display hint'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64973 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 22:59:04 +00:00
Ted Kremenek bb8c5aaa10 More fun with retain checker diagnostics:
- 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-18 22:57:22 +00:00
Ted Kremenek 1f62ef3305 Fix diagnostics bugs when computing ranges for the retain/release checker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64962 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 22:17:20 +00:00
Ted Kremenek 2701900189 retain/release checker: We now emit fancy diagnostics telling users about the
semantics of CFMakeCollectable and friends.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64956 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 21:57:45 +00:00
Ted Kremenek 1c512f5fcb retain/release checker: Distinguish in the function summaries between
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-18 18:54:33 +00:00
Ted Kremenek fe9e543a2a Hooked up the necessary machinery to allow the retain/release checker reference
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-18 03:48:14 +00:00
Ted Kremenek f5b34b120e retain/release checker: Record the summary used to generate a given node.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64876 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-18 02:00:25 +00:00
Ted Kremenek 5216ad7e09 Added GRStateManager::scanReachableSymbols(), a method which scans the reachable
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-14 03:16:10 +00:00
Ted Kremenek 41573ebf8f Static analyzer:
- 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-14 01:43:44 +00:00
Steve Naroff 389bf46ae4 Several cleanups:
- 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-12 17:52:19 +00:00
Ted Kremenek c5c6000fed Fix null dereference.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64044 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 22:54:59 +00:00
Ted Kremenek d305721d58 For retain/release leaks, have the BugReport description indicate the allocation site and initial bindings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64041 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 22:38:00 +00:00
Ted Kremenek e469fa009a Determining the allocation site for a leak when constructing a 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-07 22:19:59 +00:00
Ted Kremenek 66d9706cab Split logic for 'getEndPath()' for CFRefReport and CFRefLeakReport.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64034 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 22:04:05 +00:00
Ted Kremenek c9e3d8663a Convert a use of 'std::ostringstream' to 'llvm::raw_string_ostream'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64033 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-07 21:59:45 +00:00
Ted Kremenek a92206ea57 Add 'AppendValue' to the list of magic CF function names that cause a 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-05 22:34:53 +00:00
Ted Kremenek cf70177a9c Remove a bunch of obscene double-buffering of BugReports in the retain/release
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-05 06:50:21 +00:00
Ted Kremenek e45e57f8b8 Fix regression: Leak (BugType) object should have 'isLeak()' return true.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63803 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05 00:38:00 +00:00
Ted Kremenek cf118d41f7 Overhaul BugReporter interface and implementation. The new interface cleans up
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-02-04 23:49:09 +00:00
Ted Kremenek 6818928f39 retain/release checker: When generating summaries for CF/CG functions, allow 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-29 22:45:13 +00:00
Ted Kremenek ea4bc889a6 Remove '#if 0' code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63250 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 22:35:55 +00:00
Ted Kremenek b2bf7cda46 Remove method 'AddNE' from the public interface of ConstraintManager.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63249 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 22:27:59 +00:00
Ted Kremenek abf439731b retain/release checker: Always generate an "autorelease" summary for an "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-28 21:44:40 +00:00
Ted Kremenek 23b8eaa836 retain/release checker: Improve diagnostics to indicate that CF objects are not automatically garbage collected.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63187 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 06:25:48 +00:00
Ted Kremenek 961b61d6b4 retain/release checker: Indicate whether a tracked object is a Core Foundation or Objective-C object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63186 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 06:06:36 +00:00
Ted Kremenek a102c0c706 retain/release checker: More diagnostic refactoring.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63184 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 06:01:42 +00:00
Ted Kremenek 2d1652e0f5 retain/release checker: Embed an "object type" into the RetEffect/RetVal 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-28 05:56:51 +00:00
Ted Kremenek 611a15a18f retain/release checker: More cleanups (no real functionality change).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63181 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 05:29:13 +00:00
Ted Kremenek 103a185af4 Fix diagnostic truncated by my last patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63180 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 05:18:08 +00:00
Ted Kremenek 5c1cd520db retain/release checker: More diagnostic refactoring.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63179 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 05:15:02 +00:00
Ted Kremenek 2098280325 retain/release checker: Output the name of the function that allocates an object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63178 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 05:06:46 +00:00
Ted Kremenek a1f117e47e Refactor some diagnostic code to use raw_string_ostream. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63177 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 04:47:13 +00:00
Ted Kremenek 1d549a8cf2 Remove '#if 0' code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63176 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-28 04:37:52 +00:00
Ted Kremenek 3148eb4a75 More hacking on static analyzer diagnostics. When emitting summary 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-24 00:55:43 +00:00
Ted Kremenek 241677a13c Static Analyzer: Replace LiveSymbols/DeadSymbols sets with a new object 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-21 22:26:05 +00:00
Ted Kremenek 9989065938 Fix PR 3337 [retain/release checker]: Handle FunctionDecl's declared using typedefs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62331 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16 18:40:33 +00:00
Chris Lattner f7cf85b330 more SourceLocation lexicon change: instead of referring to the
"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-16 07:36:28 +00:00
Ted Kremenek 1261938ec4 retain/release checker:
- 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-12 21:45:02 +00:00
Ted Kremenek 234a4c286e This commit reflects changes to the retain/release checker motivated by my
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
2009-01-07 00:39:56 +00:00
Ted Kremenek 40e86d9be7 Fix regression when invalidating reference-counts for objects passed-by-reference to a function/method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61224 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-18 23:34:57 +00:00
Ted Kremenek 90b3236cbe Fix <rdar://problem/6451816>:
- Because of the introduction of AnonTypedRegions when reasoning about casts, we
  had a regression in the "symbolication" of variable values passed-by-reference
  to a function. This is now fixed in CFRefCount.cpp (-checker-cfref) by
  blasting through the layer of AnonTypedRegions when symbolicating the value of
  the variable. This logic may get moved elsewhere. Note that this change
  affects only -checker-cfref and not -checker-simple; eventually this logic
  should get pulled out of CFRefCount.cpp into a more common place. All users
  use -checker-cfref by default, and -checker-simple should probably just be
  removed.  
- Updated test 'Analysis/uninit-vals-ps.c' to only use -checker-cfref and added
  a test case for this regression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61147 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-17 19:42:34 +00:00
Ted Kremenek 6eddeb1534 MemRegion:
- Overhauled the notion of "types" for TypedRegions.  We now distinguish between the "lvalue" of a region (via getLValueRegion()) and the "rvalue" of a region (va getRValueRegion()).  Since a region represents a chunk of memory it has both, but we were conflating these concepts in some cases, leading to some insidious bugs.
- Removed AnonPointeeType, partially because it is unused and because it doesn't have a clear notion of lvalue vs rvalue type.  We can add it back once there is a need for it and we can resolve its role with these concepts.

StoreManager:
- Overhauled StoreManager::CastRegion.  It expects an *lvalue* type for a region.  This is actually what motivated the overhaul to the MemRegion type mechanism.  It also no longer returns an SVal; we can just return a MemRegion*.
- BasicStoreManager::CastRegion now overlays an "AnonTypedRegion" for pointer-pointer casts.  This matches with the MemRegion changes.
- Similar changes to RegionStore, except I've added a bunch of FIXMEs where it wasn't 100% clear where we should use TypedRegion::getRValueRegion() or TypedRegion::getLValueRegion().

AuditCFNumberCreate check:
- Now blasts through AnonTypedRegions that may layer the original memory region, thus checking if the actually memory block is of the appropriate type.  This change was needed to work with the changes to StoreManager::CastRegion.

GRExprEngine::VisitCast:
- Conform to the new interface of StoreManager::CastRegion.

Tests:
- None of the analysis tests fail now for using the "basic store".
- Disabled the tests 'array-struct.c' and 'rdar-6442306-1.m' pending further testing and bug fixing.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60995 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13 21:49:13 +00:00
Ted Kremenek 2dabd4372c Rename SymbolID to SymbolRef. This is a precursor to some overhauling of the representation of symbolic values.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60575 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05 02:27:51 +00:00
Ted Kremenek 04f9d468f7 Add FIXME.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60390 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02 01:26:07 +00:00
Chris Lattner 077bf5e2f4 Rename Selector::getName() to Selector::getAsString(), and add
a new NamedDecl::getAsString() method.

Change uses of Selector::getName() to just pass in a Selector 
where possible (e.g. to diagnostics) instead of going through
an std::string.

This also adds new formatters for objcinstance and objcclass
as described in the dox.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59933 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 03:33:13 +00:00
Ted Kremenek 062e2f9a0e GRExprEngine/CFRefCount/GRSimpleVals: We don't do any special handling (yet) of vector types. Add explicit checks that when we process integers that they really are scalars.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59225 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 06:10:40 +00:00
Ted Kremenek a441b7e913 Update method names involving GRStateRef. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59153 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 19:22:09 +00:00
Ted Kremenek d07a7b1da8 Fix regression with handling of CFMakeCollectable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58771 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-05 22:17:20 +00:00
Ted Kremenek 4c79e55951 initXXX methods can return owned objects
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58758 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-05 16:54:44 +00:00
Ted Kremenek 6ca31916ac Handle prefix '_' that may appear in front of the name of 'Release' functions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58666 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-04 00:36:12 +00:00
Sanjiv Gupta 31fc07df7f Made the mechanism of defining preprocessor defs for maxint, ptrdiff_t, wchar
etc more generic. For some targets, long may not be equal to pointer size. For
example: PIC16 has int as i16, ptr as i16 but long as i32.

Also fixed a few build warnings in assert() functions in CFRefCount.cpp,
CGDecl.cpp, SemaDeclCXX.cpp and ParseDeclCXX.cpp.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58501 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31 09:52:39 +00:00
Ted Kremenek e1e91af054 Extend "followsFundamentalRule" to ignore prefix '_' characters.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58469 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30 23:14:58 +00:00
Ted Kremenek 706522f1d5 IOServiceGetMatchingServices is a release function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58362 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-29 04:07:07 +00:00