Commit Graph

25 Commits

Author SHA1 Message Date
Ted Kremenek 8ec5771dcb Fix: <rdar://problem/7275774> Static analyzer warns about NULL pointer when
adding assert

This fix required a few changes:

SimpleSValuator:
- Eagerly replace a symbolic value with its constant value in EvalBinOpNN
  when it is constrained to a constant.  This allows us to better constant fold
  values along a path.
- Handle trivial case of '<', '>' comparison of pointers when the two pointers
  are exactly the same.

RegionStoreManager:

llvm-svn: 83358
2009-10-06 01:39:48 +00:00
Ted Kremenek 228539f015 Fix: <rdar://problem/7261075> [RegionStore] crash when handling load: '*((unsigned int *)"????")'
This issue was originally reported via personal email by Thomas Clement!

llvm-svn: 83069
2009-09-29 16:36:48 +00:00
Ted Kremenek cc22424c87 Fix really insidious bug in RegionStoreManager::RemoveDeadBindings()
identified with a false positive reported by Thomas Clement.  This
involved doing another rewrite of
RegionStoreManager::RemoveDeadBindings(), which phrases the entire
problem of scanning for dead regions as a graph exploration problem.
It is more methodic than the previous implementation.

llvm-svn: 83053
2009-09-29 06:35:00 +00:00
Ted Kremenek 5daec8a834 Reapply most of r82939, but add a guard that FieldRegions and friends
are only specially treated by RegionStore::InvalidateRegion() when
their super region is also invalidated.  When this isn't the case,
conjure a new symbol for a FieldRegion.  Thanks to Zhongxing Xu and
Daniel Dunbar for pointing out this issue.

llvm-svn: 83043
2009-09-29 03:34:03 +00:00
Ted Kremenek e41b81e9ab Fix:
<rdar://problem/6914474> checker doesn't realize that variable might
have been assigned if a pointer to that variable was passed to another
function via a structure

The problem here was the RegionStoreManager::InvalidateRegion didn't
invalidate the bindings of invalidated regions.  This required a
rewrite of this method using a worklist.

As part of this fix, changed ValueManager::getConjuredSymbolVal() to
require a 'void*' SymbolTag argument.  This tag is used to
differentiate two different symbols created at the same location.

llvm-svn: 82920
2009-09-27 20:45:21 +00:00
Ted Kremenek f694f421e1 Fix <rdar://problem/7249327> by allowing silent conversions between signed and unsigned integer values for symbolic values. This is an intermediate solution (i.e. hack) until we support extension/truncation of symbolic integers.
llvm-svn: 82737
2009-09-25 00:18:15 +00:00
Ted Kremenek 1b40e5978f Fix crash in RegionStoreManager::Bind() by using 'getAs<PointerType>()' instead of 'cast<PointerType>()' (to handle pointer typedefs).
llvm-svn: 82686
2009-09-24 06:24:32 +00:00
Ted Kremenek 267e45adab Fix: <rdar://problem/7249340> [RegionStore] model stores to symbolic parameter regions
The issue was a discrepancy between how RegionStoreManager::Bind() and
RegionStoreManager::Retrieve() derived the "key" for the first element
of a symbolic region.

llvm-svn: 82680
2009-09-24 04:11:44 +00:00
Ted Kremenek 3003001a86 Fix: <rdar://problem/7242006> [RegionStore] compound literal assignment with floats not honored
llvm-svn: 82575
2009-09-22 21:19:14 +00:00
Ted Kremenek 25c9c1427a Provide intermediate solution to handling assignments to structs via an
integer pointer.  For now just invalidate the fields of the struct.

This addresses: <rdar://problem/7185607> [RegionStore] support invalidation of bit fields using integer assignment

llvm-svn: 82492
2009-09-21 22:58:52 +00:00
Ted Kremenek 2f6eb14af4 Fix a couple false positive "uninitialized value" warnings with RegionStore
involving reasoning about unions (which we don't handle yet).

llvm-svn: 78342
2009-08-06 21:43:54 +00:00
Zhongxing Xu 13ee441874 Add test case.
llvm-svn: 78150
2009-08-05 03:45:09 +00:00
Ted Kremenek d7e467f39c Add test case testing field sensitivity. Reduced from <rdar://problem/7114618>.
llvm-svn: 78008
2009-08-03 22:23:24 +00:00
Ted Kremenek 6ab0a74a25 Add test case for bug fix in r76262.
llvm-svn: 76283
2009-07-18 05:02:33 +00:00
Ted Kremenek e6fea68c46 More test cases revealed that the logic in StoreManager::InvalidateRegion() needs more finesse when handling the invalidation of pointers. Pointers that were invalidated as integers could later cause problems for clients using them as pointers. It is easier for us to model a symbolic value as a pointer rather than modeling a non-symbolic value as a pointer.
This patch causes:
- StoreManager::InvalidateRegion() to not used the casted type of a region if
  it would cause a pointer type to be invalidated as a non-pointer type.
- Pushes RegionStore::RetrieveElement() further by handling retrievals from
  symbolic arrays that have been invalidated.  This uses the new SymbolDerived
  construct that was recently introduced.
  
The result is that the failing test in misc-ps-region-store-x86_64.m now passes.
Both misc-ps-region-store-x86_64.m and misc-ps-region-store-i386.m contain a
test case that motivated this change.

llvm-svn: 75730
2009-07-15 02:31:43 +00:00
Ted Kremenek 9a797db199 Split out 'test2' into an i386 and x86_64 file, illustrating how the
test behavior differs between architectures.  When this is no longer
the case, these tests will be merged.

llvm-svn: 75708
2009-07-14 23:17:22 +00:00
Ted Kremenek eea582f04f This test currently only passes for 32-bit archs.
llvm-svn: 75698
2009-07-14 22:58:18 +00:00
Ted Kremenek 0c37d19fea Enhance RegionStoreManager to handle 'Retrieve's from SymbolicRegions. We do this by silently wrapping the region with an ElementRegion. This fixes the failures in misc-ps-region-store.m.
llvm-svn: 75679
2009-07-14 20:48:22 +00:00
Ted Kremenek b63f71528e Enhance SimpleSValuator::EvalBinOpNN to recognize the trivial case
where we are comparing a symbolic value against itself, regardless of
the nature of that symbolic value.

This enhancement identified a case where RegionStoreManager is not
correctly symbolicating the values of the pointees of parameters.  The
failing test is now in 'test/Analysis/misc-ps-region-store.m', with
that test file now (temporarily) marked XFAIL.

llvm-svn: 75521
2009-07-13 21:55:12 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +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 77a3cb2dfa Add test case for RegionStore's tracking of the ivars of 'self'.
llvm-svn: 66136
2009-03-05 04:55:08 +00:00
Ted Kremenek 33129a26f7 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.

llvm-svn: 66094
2009-03-04 22:56:43 +00:00
Ted Kremenek b535181199 Static Analyzer driver/options (partial) cleanup:
- Move all analyzer options logic to AnalysisConsumer.cpp.
- Unified specification of stores/constraints/output to be:
   -analyzer-output=...
   -analyzer-store=...
   -analyzer-constraints=...
  instead of -analyzer-range-constraints, -analyzer-store-basic, etc.
- Updated drivers (ccc-analyzer, scan-builds, new ccc) to obey this new
  interface
- Updated test cases to conform to new driver options

llvm-svn: 64737
2009-02-17 04:27:41 +00:00
Ted Kremenek 556c3709d6 The 'misc-ps.m' test case now passes with RegionStore. One case needed to be split out into 'misc-ps-basic-store.m' and 'misc-ps-region-store.m' because the behavior was different between the two store models (RegionStore flags an additional valid bug).
llvm-svn: 62772
2009-01-22 18:53:15 +00:00