Commit Graph

873 Commits

Author SHA1 Message Date
Ted Kremenek b294d196b3 analyzer: Provide temporary workaround for false positive reported by
<rdar://problem/6704930> involving SimpleConstraintManager not reasoning well
about symbolic constraint values involving arithmetic operators.

llvm-svn: 67534
2009-03-23 17:10:25 +00:00
Ted Kremenek c7fef2ad53 analyzer: Fix embarrassing regression in BasicStore when invalidating struct
values passed-by-reference to unknown functions.

llvm-svn: 67519
2009-03-23 15:42:58 +00:00
Ted Kremenek 6b31533ad1 GRExprEngine:
- Conjure symbols at '--' and '++' unary operations
- Add utility method SVal::GetConjuredSymbolVal() and constify some arguments
  along the way.

llvm-svn: 67395
2009-03-20 20:10:45 +00:00
Ted Kremenek 8c3f0047b4 retain/release checker: Tracking autorelease counts for objects. We're still not
completely there with accurately modeling autorelease pools.

llvm-svn: 67384
2009-03-20 17:34:15 +00:00
Ted Kremenek 891642e4da Fix PR 3836 by eagerly assuming symbolic constraints returned by unary '!'.
llvm-svn: 67260
2009-03-18 23:49:26 +00:00
Ted Kremenek b36e01d87e Fix crash reported in <rdar://problem/6695527>. We now have
SVal::GetRValueSymbolVal do the checking if we can symbolicate a type instead of
having BasicStoreManager do it (which wasn't always doing the check
consistently). Having this check in SVal::GetRValueSymbolVal keeps the check in
one centralized place.

llvm-svn: 67245
2009-03-18 22:10:22 +00:00
Zhongxing Xu 17299e6172 Use a work list to recursively build up the subregion mapping, and mark live
var region roots.

llvm-svn: 67152
2009-03-18 01:54:31 +00:00
Ted Kremenek 211094d793 Stub out some code for support for NSDeallocateObject. This is enabled yet until
we resolve the semantics of this function when GC is enabled.

llvm-svn: 67116
2009-03-17 22:43:44 +00:00
Ted Kremenek ea072e3cae retain/release checker: Add support for reasoning about -dealloc.
llvm-svn: 67094
2009-03-17 19:42:23 +00:00
Douglas Gregor 23d75bb326 Build system changes to use TableGen to generate the various
diagnostics. This builds on the patch that Sebastian committed and
then revert. Major differences are:

  - We don't remove or use the current ".def" files. Instead, for now,
    we just make sure that we're building the ".inc" files.
  - Fixed CMake makefiles to run TableGen and build the ".inc" files
    when needed. Tested with both the Xcode and Makefile generators
    provided by CMake, so it should be solid.
  - Fixed normal makefiles to handle out-of-source builds that involve
    the ".inc" files.

I'll send a separate patch to the list with Sebastian's changes that
eliminate the use of the .def files.

llvm-svn: 67058
2009-03-16 23:06:59 +00:00
Ted Kremenek 340fd2dd6e Fix PR 3677 [retain checker]: custom 'allocWithZone' methods should be allowed
to return an owning pointer.

llvm-svn: 66934
2009-03-13 20:27:06 +00:00
Ted Kremenek 22358bd681 Add a hack in the analyzer to recover some path-sensitivity at branch
conditions. Currently the analyzer does not reason well about
promotions/truncations of symbolic values, so at branch conditions when we see:

  if (condition)
  
and condition is something like a 'short' or 'char', essentially ignore the
promotion to 'int' so that we track constraints on the original symbolic value.
We only ignore the casts if the underlying type has the same or fewer bits as
the converted type.

This fixes:

<rdar://problem/6619921>

llvm-svn: 66899
2009-03-13 16:32:54 +00:00
Ted Kremenek 0bf152ef0b Updated comment.
llvm-svn: 66894
2009-03-13 15:39:16 +00:00
Ted Kremenek ec94f08dce Fix failure reported by Sebastian of test/Analysis/ptr-arith.c when the target
is 64-bit. I used his suggestion of doing a direct bitwidth/signedness
conversion of the 'offset' instead of just changing the sign. For more
information, see:

http://lists.cs.uiuc.edu/pipermail/cfe-dev/2009-March/004587.html

llvm-svn: 66892
2009-03-13 15:35:24 +00:00
Ted Kremenek e413a76004 Use the correct data structures!
ExplodedGraph::TrimGraph:
- Just do a DFS both ways instead of BFS-DFS. We're just determining what subset
  of the nodes are reachable from the root and reverse-reachable from the bug
  nodes.  DFS is more efficient for this task.
  
BugReporter:
- MakeReportGraph: Do a reverse-BFS instead of a reverse-DFS to determine the
  approximate shortest path through the simulation graph. We were seeing some
  weird cases where too many loops were being reported for simple bugs. Possibly
  we will need to replace this with actually computing the shortest path in
  terms of line numbers.

llvm-svn: 66842
2009-03-12 23:41:59 +00:00
Ted Kremenek 9d1ce8faae PathDiagnostics:
- PathDiagnosticControlFlowPiece now consists of a "start" and "end" location
  to indicating the branch location and where the branch goes.

BugReporter:
- Updated BugReporter to construct PathDiagnosticControlFlowPiece objects with
  "end" locations.

PlistDiagnostics:
- Plists now contain the bug "type" (not just bug "category")
- Plists now encode control-flow pieces differently than events; now the
  "start" and "end" locations are recorded

llvm-svn: 66818
2009-03-12 18:41:53 +00:00
Zhongxing Xu 15adce4ea2 Add comments.
llvm-svn: 66782
2009-03-12 07:54:17 +00:00
Zhongxing Xu 5a6fee9fb8 Use getAsRecordType() to get around sugar types.
llvm-svn: 66768
2009-03-12 03:45:35 +00:00
Ted Kremenek f9351cff98 Remove '[naming convention]' from bug type.
llvm-svn: 66739
2009-03-11 23:43:16 +00:00
Ted Kremenek 0f4b0d27f8 Add TypedViewRegion::isBoundable() to indicate whether or not the
TypedViewRegion has a valid rvalue type. Also renamed instance variable 'T' to
'LvalueType' to make it unambiguous of its purpose.

This fixes some crashes I was seeing after:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090309/013771.html

This is because 'isBoundable()' is defined in TypedRegion (the parent class) in
terms of the rvalue type (which could be null), while for TypedViewRegion it
should be defined in terms of the lvalue type.

llvm-svn: 66712
2009-03-11 21:57:34 +00:00
Zhongxing Xu d2e89ae055 Do not stipulate the record type is a definition in BindStruct().
llvm-svn: 66654
2009-03-11 09:07:35 +00:00
Zhongxing Xu 507202ecb7 Fix crash when LHS of pointer arithmetic is not ElementRegion.
llvm-svn: 66649
2009-03-11 07:43:49 +00:00
Ted Kremenek 90e213f025 RegionStore::getLValueElement: Handle the case where the signedness of the
offset may be different that the base. Ultimately we need a better solution for
these issues, but this point-by-point fixes are gradually outlining the scope of
the problem.

llvm-svn: 66638
2009-03-11 04:04:20 +00:00
Ted Kremenek 32c41ec66e GRExprEngine::ProcessBranch: Don't register a "pretty-stack printer" when the Condition is null.
llvm-svn: 66636
2009-03-11 03:54:24 +00:00
Ted Kremenek 0fa538528e Fix PR 3780: In one code path in BasicValueFactory::getValue() we would not
return an unsigned integer for a null pointer value.

llvm-svn: 66630
2009-03-11 02:52:39 +00:00
Ted Kremenek 91076caabf GRExprEngine: Add pretty-stack trace printing for crashes and assertion failures.
llvm-svn: 66629
2009-03-11 02:41:36 +00:00
Ted Kremenek 3f5a85ad06 SimpleConstraintManager doesn't reason about bitwise-constraints on symbolic
values. Indicating this in 'canReasonAbout' allows GRExprEngine to recover
path-sensitivity in some cases.

llvm-svn: 66628
2009-03-11 02:29:48 +00:00
Ted Kremenek 44c12ef615 GRExprEngine: For places we might conjure up a new symbol to recover
path-sensitivity, beyond checking to see if the value is "unknown" also check if
the ConstraintManager can handle the SVal. This allows us to recover some
path-sensitivity by actually discarding some information.

llvm-svn: 66627
2009-03-11 02:24:48 +00:00
Ted Kremenek 4e34f958f4 Added method "canReasonAbout" to ConstraintManager. This method returns true if
a ConstraintManager can usefully reason about the given SVal.

llvm-svn: 66624
2009-03-11 02:22:59 +00:00
Ted Kremenek 95175052b2 Use the BugReports in BugReporter to determine the root nodes for "trim-egraph".
llvm-svn: 66622
2009-03-11 01:41:22 +00:00
Daniel Dunbar 4095d89532 Remove some now-unneeded calls to llvm::errs().flush().
llvm-svn: 66555
2009-03-10 18:00:19 +00:00
Ted Kremenek b4947e4378 BugReporter:
- Group control flow and event PathDiagnosticPieces into PathDiagnosticMacroPieces.
- Afterwards, eliminate any PathDiagnosticMacroPieces from a PathDiagnostic that
  contain no informative events.

HTMLDiagnostics:
- Use new information about PathDiagnosticMacroPieces to specially format
  message bubbles for macro expansions containing interesting events.

llvm-svn: 66524
2009-03-10 05:16:17 +00:00
Ted Kremenek 0b891a343a retain/release checker: Allow allocations to fail by returning nil.
llvm-svn: 66487
2009-03-09 22:46:49 +00:00
Ted Kremenek 0603222888 RegionStore::getElementLValue(): Handle the case where the base is a null pointer.
llvm-svn: 66486
2009-03-09 22:44:49 +00:00
Ted Kremenek 06eb672f24 Teach GRSimpleVals::EvalNE and GRSimplVals::EvalEQ about TypedRegionViews and
SymbolicRegions. This fixes a serious regression when checking symbolic pointers
against null.

llvm-svn: 66444
2009-03-09 20:35:15 +00:00
Ted Kremenek 701e487520 Remove some dead spacing. No functionality change.
llvm-svn: 66437
2009-03-09 20:26:47 +00:00
Zhongxing Xu 7219d1bada Only track integer and pointer values.
llvm-svn: 66419
2009-03-09 09:31:22 +00:00
Zhongxing Xu ce270a6dbc Now we do not retrieve untyped regions.
llvm-svn: 66418
2009-03-09 09:15:51 +00:00
Zhongxing Xu b09280bcc0 Fix a serious bug in RegionStore: we got the new state with new store from
Bind() and BindStruct(), but we returned a state with the old store.

llvm-svn: 66409
2009-03-09 06:49:50 +00:00
Ted Kremenek b6b7ce4b50 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.

llvm-svn: 66310
2009-03-06 23:58:11 +00:00
Ted Kremenek 81bddcb61e Start work on subclassing PathDiagnosticPiece to distinguish more between control-flow pieces, events, etc.
llvm-svn: 66291
2009-03-06 22:10:49 +00:00
Ted Kremenek 55f46f6aab Fix regression: initialize 'size' for PathDiagnostic to 0.
Add some assertions along the way...

llvm-svn: 66265
2009-03-06 07:53:30 +00:00
Ted Kremenek 5b9e7b833b Like PathDiagnosticPieces, strip trailing periods at the end of PathDiagnostic descriptions
llvm-svn: 66263
2009-03-06 07:08:50 +00:00
Ted Kremenek 3add5e51ff Fix another GRExprEngine::VisitCast regression: handle casts of void* to function pointers.
llvm-svn: 66211
2009-03-05 22:47:06 +00:00
Ted Kremenek 5f968930d7 Minor tweak: Recognize 'CGCF' prefix in addition to 'CF' and 'CG'.
llvm-svn: 66208
2009-03-05 22:11:14 +00:00
Ted Kremenek a06a68fa9b Fix regression in GRExprEngine::VisitCast: Do not wrap symbolic function pointers with TypedViewRegions.
llvm-svn: 66187
2009-03-05 20:22:13 +00:00
Ted Kremenek fa3d77bc2c Retrofit some basic tracking of ivars (for the current object) into BasicStore.
llvm-svn: 66166
2009-03-05 18:08:28 +00:00
Ted Kremenek 89f4781703 Minor code compaction. No functionality change.
llvm-svn: 66165
2009-03-05 16:41:21 +00:00
Ted Kremenek 1fe63ac93d Rename VarBindings -> Bindings.
llvm-svn: 66164
2009-03-05 16:32:59 +00:00
Ted Kremenek 2f340d6cb6 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*)

llvm-svn: 66163
2009-03-05 16:31:07 +00:00