| Commit message (Collapse) | Author | Age | Files | Lines | 
| | 
| 
| 
| 
| 
|  | 
getBaseRegion will be used in another method.
llvm-svn: 86649
 | 
| | 
| 
| 
|  | 
llvm-svn: 84081
 | 
| | 
| 
| 
|  | 
llvm-svn: 81346
 | 
| | 
| 
| 
| 
| 
| 
| 
|  | 
pointers.  Most logic cares first about whether or not a region is
symbolic, and second if represents code.  This should fix a series of
silent corner case bugs (as well as simplify a bunch of code).
llvm-svn: 80335
 | 
| | 
| 
| 
| 
| 
| 
|  | 
implicit cast logic in RegionStoreManager to BasicStoreManager. This involved
moving CastRetriedVal from RegionStoreManager to StoreManager.
llvm-svn: 80026
 | 
| | 
| 
| 
| 
| 
|  | 
'void*' (or 'const void*') as an identity transformation.
llvm-svn: 77860
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
made to RegionStore (and related classes) in order to handle some
analyzer failures involving casts and manipulation of symbolic memory.
The root of the change is in StoreManager::CastRegion().  Instead of
using ad hoc heuristics to decide when to layer an ElementRegion on a
casted MemRegion, we now always layer an ElementRegion when the cast
type is different than the original type of the region.  This carries
the current cast information associated with a region around without
resorting to the error prone recording of "casted types" in GRState.
Along with this new policy of layering ElementRegions, I added a new
algorithm to strip away existing ElementRegions when they simply
represented casts of a base memory object.  This algorithm computes
the raw "byte offset" that an ElementRegion represents from the base
region, and allows the new ElementRegion to be based off that offset.
The added benefit is that this naturally handles a series of casts of
a MemRegion without building up a set of redundant ElementRegions
(thus canonicalizing the region view).
Other related changes that cascaded from this one (as tests were
failing in RegionStore):
- Revamped RegionStoreManager::InvalidateRegion() to completely remove
  all bindings and default values from a region and all subregions.
  Now invalidated fields are not bound directly to new symbolic
  values; instead the base region has a "default" symbol value from
  which "derived symbols" can be created.  The main advantage of this
  approach is that it allows us to invalidate a region hierarchy and
  then lazily instantiate new values no matter how deep the hierarchy
  went (i.e., regardless of the number of field accesses,
  e.g. x->f->y->z->...).  The previous approach did not do this.
- Slightly reworked RegionStoreManager::RemoveDeadBindings() to also
  incorporate live symbols and live regions that do not have direct
  bindings but also have "default values" used for lazy instantiation.
  The changes to 'InvalidateRegion' revealed that these were necessary
  in order to achieve lazy instantiation of values in the region store
  with those bindings being removed too early.
- The changes to InvalidateRegion() and RemoveDeadBindings() revealed
  a serious bug in 'getSubRegionMap()' where not all region -> subregion
  relationships involved in actually bindings (explicit and implicit)
  were being recorded.  This has been fixed by using a worklist algorithm
  to iteratively fill in the region map.
- Added special support to RegionStoreManager::Bind()/Retrieve() to handle
  OSAtomicCompareAndSwap in light of the new 'CastRegion' changes and the
  layering of ElementRegions.
- Fixed a bug in SymbolReaper::isLive() where derived symbols were not
  being marked live if the symbol they were derived from was also live.
  This fix was critical for getting lazy instantiation in RegionStore
  to work.
- Tidied up the implementation of ValueManager::getXXXSymbolVal() methods
  to use SymbolManager::canSymbolicate() to decide whether or not a
  symbol should be symbolicated.
- 'test/Analysis/misc-ps-xfail.m' now passes; that test case has been
  moved to 'test/Analysis/misc-ps.m'.
- Tweaked some pretty-printing of MemRegions, and implemented
  'ElementRegion::getRawOffset()' for use with the CastRegion changes.
llvm-svn: 77782
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.
This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.
llvm-svn: 77510
 | 
| | 
| 
| 
| 
| 
| 
|  | 
OldCastRegion used), and the associated command line option
'-analyzer-store=old-basic-cast'.
llvm-svn: 77509
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
in StoreManager to RegionStoreManager, and create a special, highly reduced
version in BasicStoreManager.
These changes are in preparation for future RegionStore-specific changes to
InvalidateRegion.
llvm-svn: 77483
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
|  | 
'cast type' of a region to invalidate its binding.  This only occurs
when using RegionStoreManager, as it records the cast type.  I'm
currently considering removing the notion of a cast type (see
comments in code).
llvm-svn: 76719
 | 
| | 
| 
| 
| 
| 
|  | 
whatever) to a BlockPointerType.
llvm-svn: 76288
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
|  | 
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.
llvm-svn: 76193
 | 
| | 
| 
| 
| 
| 
|  | 
Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
llvm-svn: 76139
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.
The motivation behind this change is twofold:
1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.
2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.
Along with this patch:
a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.
llvm-svn: 76098
 | 
| | 
| 
| 
| 
| 
|  | 
Convert all clients to use the new predicate on Type.
llvm-svn: 76076
 | 
| | 
| 
| 
|  | 
llvm-svn: 75750
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
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
 | 
| | 
| 
| 
|  | 
llvm-svn: 75713
 | 
| | 
| 
| 
| 
| 
| 
| 
|  | 
invalidate the region correctly. It uses the cast-to type to invalidate 
the region when available. To avoid invalid cast-to type like 'void*' or 'id',
region store now only records non-generic casts of regions.
llvm-svn: 75580
 | 
| | 
| 
| 
| 
| 
| 
| 
|  | 
CodeTextRegions can only be casted to FunctionPointer or BlockPointerTypes. This
simply isn't true. We can handle bogus operations on CodeTextRegions (e.g, an
array access) elsewhere.
llvm-svn: 75285
 | 
| | 
| 
| 
| 
| 
|  | 
void**, void***, etc.  Such casts should just pass the region through.
llvm-svn: 75281
 | 
| | 
| 
| 
|  | 
llvm-svn: 74890
 | 
| | 
| 
| 
| 
| 
|  | 
types.
llvm-svn: 74884
 | 
| | 
| 
| 
|  | 
llvm-svn: 74877
 | 
| | 
| 
| 
| 
| 
| 
|  | 
region type. This better shows the logic of the method and allows the compiler
to check if we didn't handle a specific region kind.
llvm-svn: 74876
 | 
| | 
| 
| 
|  | 
llvm-svn: 74875
 | 
| | 
| 
| 
|  | 
llvm-svn: 74874
 | 
| | 
| 
| 
|  | 
llvm-svn: 74872
 | 
| | 
| 
| 
| 
| 
| 
| 
|  | 
- Refactor logic that creates ElementRegions into a help method 'MakeElementRegion'.
- Fix crash due to not handling StringRegions.  Casts of StringRegions now
  result in a new ElementRegion layered on the original StringRegion.
llvm-svn: 74867
 | 
| | 
| 
| 
| 
| 
| 
|  | 
- Have test for 'CodeTextRegion' dominate other region tests.
- Use 'getAsRecordType' instead of isa<RecordType>
llvm-svn: 74853
 | 
| | 
| 
| 
|  | 
llvm-svn: 74852
 | 
| | 
| 
| 
| 
| 
| 
|  | 
(its superclass). This will allow us to experiment with using the new CastRegion
with BasicStoreManager, and gradually phase out the old implementation.
llvm-svn: 74851
 | 
| | 
| 
| 
|  | 
llvm-svn: 74816
 | 
| | 
| 
| 
| 
| 
|  | 
No functionality change. 
llvm-svn: 74812
 | 
| | 
| 
| 
| 
| 
| 
| 
|  | 
TypedRegion. While we plan on removing this code at some point, it serves as a
good reference implementation for use with BasicStore until we are sure the new
CastRegion logic (in RegionStore.cpp) is correct.
llvm-svn: 74559
 | 
| | 
| 
| 
| 
| 
|  | 
be unique.
llvm-svn: 73482
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
|  | 
RValueType => ObjectType
 LValueType => LocationType
No functionality change.
llvm-svn: 71304
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
- Update the old StoreManager::CastRegion to strip off 'ElementRegions' when
  casting to void* (Zhongxing: please validate)
- Pass-by-reference argument invalidation logic in CFRefCount.cpp:
  - Strip ElementRegions when the ElementRegion is just a 'raw data' view
    on top of the underlying typed region.
llvm-svn: 71094
 | 
| | 
| 
| 
|  | 
llvm-svn: 70865
 | 
| | 
| 
| 
|  | 
llvm-svn: 70864
 | 
| | 
| 
| 
| 
| 
| 
|  | 
no-outofbounds.c still fails. Previously it passed because the array index
is mistakenly a loc::ConcreteInt.
llvm-svn: 70844
 | 
| | 
| 
| 
| 
| 
| 
|  | 
StoreManager: Handle casts from one element region to another.
Update test cases.
llvm-svn: 70836
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
|  | 
'ElementRegion' on top of the VarRegion for 'x'.  This causes the test
case xfail_wine_crash.c to now pass for BasicStoreManager.  It doesn't
crash for RegionStoreManager either, but reports a bogus unintialized
value warning.
llvm-svn: 70832
 | 
| | 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
| 
|  | 
- Don't layer TypedViewRegions on top of any region except
  SymbolicRegions and AllocaRegions.  This follows from my offline
  discussion within Zhongxing about how TypedViewRegions really only
  represent memory getting re-appropriated for a new purpose.
Fallout	from this change:
- Move test case from xfail_rdar_6440393.m to misc-ps-64.m
  (it now passes).
- test/Analysis/fields.c now fails for region store (crash).
  Marking XFAIL.
- test/Analysis/rdar-6441136-region.c now fails (only runs with region store).
  Marking XFAIL.
  Diagnosis: The analyzer now correctly identifies an early out-of-bounds memory
   access then the one flagged:
  rdar-6541136-region.c:17:3: warning: Load or store into an out-of-bound memory position.
    *p = 1;
    ^~
  Changing the line:
   char *p = (void*) &wonky[1];
  to
   char *p = (void*) &wonky[0];
  (which should delay the buffer overrun) causes region store to crash, probably
  because it expects a TypedViewRegion.
- test/Analysis/casts.c (region store) now fails (crash).
  Marking XFAIL.
llvm-svn: 70565
 | 
| | 
| 
| 
| 
| 
| 
| 
|  | 
some refactoring I did recently to StoreManager.
StoreManager::CastRegion: Handle casts to void* by stripping TypedViewRegions.
llvm-svn: 69751
 | 
|   
  
  
  
  
  
  
   | 
into StoreManager::CastRegion. Both methods were practically identical, and this
is core logic that is common to all StoreManagers since it defines the basic
invariants of the abstract memory model.
llvm-svn: 69730
 |