Jordy Rose
df28e8ec41
- Allow making ElementRegions with complex offsets (expressions or symbols) for the purpose of bounds-checking.
...
- Rewrite GRState::AssumeInBound to actually do that checking, and to use the normal constraint path.
- Remove ConstraintManager::AssumeInBound.
- Teach RegionStore and FlatStore to ignore those regions for now.
llvm-svn: 111116
2010-08-16 01:15:17 +00:00
Zhongxing Xu
ee770d40fd
StoreManager::RemoveDeadBindings() can take a Store instead of an entire GRState now.
...
llvm-svn: 111103
2010-08-15 12:45:09 +00:00
Zhongxing Xu
0ba9fd6c47
Remove redundant method.
...
llvm-svn: 111099
2010-08-15 10:08:38 +00:00
Jordy Rose
ac0ab20e3b
Add a callback for when region changes occur. Still somewhat of a work-in-progress, but working! Effect on clients: all changes to a store now go through GRState.
...
llvm-svn: 111078
2010-08-14 20:44:32 +00:00
Zhongxing Xu
8de0a3d8c3
MemRegion can refer to ASTContext without external help.
...
llvm-svn: 110784
2010-08-11 06:10:55 +00:00
Jordy Rose
c88c74cb2f
Remove InvalidateRegion from stores, since it's no longer called from outside.
...
llvm-svn: 110309
2010-08-05 03:28:45 +00:00
Jordy Rose
ddec092641
Makes GRState::makeWithStore private, to encourage clients to make store changes through GRState instead of directly accessing the StoreManager. Also adds cover methods for InvalidateRegion(s) and EnterStackFrame to GRState.
...
This is in preparation for proposed region change notifications. No functionality change.
llvm-svn: 110137
2010-08-03 20:44:35 +00:00
Zhongxing Xu
fd91d27630
Improve flat store: MemRegion::getAsOffset() computes a region's offset within
...
the top-level object. FlatStore now can bind and retrieve element and field
regions.
PR7297 is fixed by flat store.
llvm-svn: 110020
2010-08-02 04:56:14 +00:00
Jordy Rose
daa1c83413
Use a LazyCompoundVal to handle initialization with a string literal, rather than copying each character.
...
llvm-svn: 109734
2010-07-29 06:40:33 +00:00
Ted Kremenek
385f71b1f4
Augment RegionStore::BindStruct() to bind symbolicated struct values. This fixes a false path issue reported in <rdar://problem/8243408> and also spurs another cause where the idempotent operations checker fires.
...
llvm-svn: 109710
2010-07-29 00:28:47 +00:00
Ted Kremenek
da534381f8
Fix casts in RegionStore to not always assume that bindings are only to SubRegions. Fixes assertion failure
...
reported in PR 7572.
llvm-svn: 107738
2010-07-06 23:53:29 +00:00
Jordy Rose
674bd55f02
Add a new symbol type, SymbolExtent, to represent the extents of memory regions that may not be known at compile-time (such as those created by malloc). This replaces the old setExtent/getExtent API on Store, which used the GRState's GDM to store SVals.
...
Also adds a getKnownValue() method to SValuator, which gets the integer value of an SVal if it is known to only have one possible value. There are more places in the code that could be using this, but in general we want to be dealing entirely in SVals, so its usefulness is limited.
The only visible functionality change is that extents are now honored for any DeclRegion, such as fields and Objective-C ivars, rather than just variables. This shows up in bounds-checking and cast-size-checking.
llvm-svn: 107577
2010-07-04 00:00:41 +00:00
Ted Kremenek
bd862711fd
Fix PR 7475 by enhancing the static analyzer to also invalidate bindings for non-static global variables
...
when calling a function/method whose impact on global variables we cannot accurately estimate.
This change introduces two new MemSpaceRegions that divide up the memory space of globals, and causes
RegionStore and BasicStore to consult a binding to the NonStaticGlobalsMemSpaceRegion when lazily
determining the value of a global.
llvm-svn: 107423
2010-07-01 20:16:50 +00:00
Jordy Rose
f7488ec6dc
Add an ivar to SymbolReaper for the current statement, and then stop passing the current statement around everywhere. Preparation for symbolic extents.
...
llvm-svn: 107422
2010-07-01 20:09:55 +00:00
Jordy Rose
61176897ba
Pointer comparisons (and pointer-pointer subtraction). Basically filling in SimpleSValuator::EvalBinOpLL().
...
llvm-svn: 106992
2010-06-28 08:26:15 +00:00
Jordy Rose
c3bcc36a0b
When a constant size array is casted to another type, its length should be scaled as well.
...
llvm-svn: 106911
2010-06-25 23:23:04 +00:00
Tom Care
375387d1f8
Change RegionStoreManager::Retrieve to infer the type of a symbolic region from the context when it is not already available.
...
llvm-svn: 106868
2010-06-25 18:22:31 +00:00
Ted Kremenek
2a33a0deef
Correctly construct an ElementRegion for alloca() + pointer arithmetic. Fixes analyzer
...
crash reported in PR 7450.
llvm-svn: 106609
2010-06-22 23:58:31 +00:00
Ted Kremenek
648ef7a2d7
Implement RegionStoreManager::iterBindings(). This implementation only returns the base region in
...
the binding key instead of the region + offset. It isn't clear if this is the best semantics, but most
clients will likely only care about simple bindings, or bindings to a particular variable. We can
refine later if necessary.
llvm-svn: 106183
2010-06-17 00:24:42 +00:00
Zhongxing Xu
ce83656f97
Limit the use of BindDefault().
...
llvm-svn: 105265
2010-06-01 04:49:26 +00:00
Zhongxing Xu
527ff6d1dc
Add support for calloc() in MallocChecker. Patch by Jordy Rose, with my
...
modification.
llvm-svn: 105264
2010-06-01 03:01:33 +00:00
Ted Kremenek
4708f5a89b
After conversations with Zhongxing Xu and Jordy Rose, refine the logic in
...
RegionStoreManager::RetrieveElement() that handles indexing into a larger scalar
object to only consult the direct binding of a super region if it is a scalar.
This isn't perfect yet, and a big FIXME is attached to the code. This causes
the test case for PR 7218 now to pass.
llvm-svn: 105195
2010-05-31 01:22:04 +00:00
Zhongxing Xu
94aec9381d
Revert r105097. Thinking about a better fix.
...
llvm-svn: 105099
2010-05-29 06:49:04 +00:00
Zhongxing Xu
928a190a8e
Fix PR7218. Patch by Jordy Rose.
...
llvm-svn: 105097
2010-05-29 06:23:24 +00:00
Zhongxing Xu
eb4fc4a64c
Small fix.
...
llvm-svn: 104669
2010-05-26 03:36:08 +00:00
Zhongxing Xu
d4f1294f1e
Remove extents of dead symbolic regions when RemoveDeadBindings.
...
This requires creating new persistent states due to the nature of GDM.
llvm-svn: 104668
2010-05-26 03:27:35 +00:00
Zhongxing Xu
658dd8b176
CastSizeChecker checks when casting a malloc'ed symbolic region to type T,
...
whether the size of the symbolic region is a multiple of the size of T.
Fixes PR6123 and PR7217.
llvm-svn: 104584
2010-05-25 04:59:19 +00:00
Douglas Gregor
8385a06929
Introduce Type::isStructureOrClassType(), which does the obvious
...
thing. Audit all uses of Type::isStructure(), changing those calls to
isStructureOrClassType() as needed (which is alsmost
everywhere). Fixes the remaining failure in Boost.Utility/Swap.
llvm-svn: 102386
2010-04-26 21:31:17 +00:00
Zhongxing Xu
b6843f5f35
Analyzer: add support for CXXNewExpr.
...
llvm-svn: 101771
2010-04-19 11:47:28 +00:00
Ted Kremenek
26984fb4eb
Remove copy of 'Optional' in Clang tree, and convert clients to use the one now in the LLVM tree.
...
llvm-svn: 100891
2010-04-09 20:26:58 +00:00
Zhongxing Xu
640aad7667
Use the element type to compute the array size when the base region is a VarRegion.
...
Patch by Jordy Rose.
llvm-svn: 100099
2010-04-01 08:20:27 +00:00
Ted Kremenek
c3e1f2f9ba
Fix a bug (PR 6699) in RegionStore::RemoveDeadBindings() where
...
array values with a non-zero offset would get prematurely pruned from the store.
llvm-svn: 100067
2010-04-01 00:15:55 +00:00
Ted Kremenek
2d107f9d1d
RegionStore: specially handle loads from integer global variables declared 'const'.
...
Fixes a false positive reported in PR 6288.
llvm-svn: 99922
2010-03-30 20:31:04 +00:00
Ted Kremenek
f7c226da00
Use 'const Optional<SVal>&' to avoid an extra copy.
...
llvm-svn: 99921
2010-03-30 20:30:52 +00:00
Zhongxing Xu
e248dca300
Bind the constructed object value to CXXConstructExpr.
...
llvm-svn: 99271
2010-03-23 09:13:17 +00:00
Zhongxing Xu
03fd76663e
Mark CXXThisRegion in the current or parent stack frame context as live so that
...
their bindings are not removed.
llvm-svn: 98705
2010-03-17 03:35:08 +00:00
Zhongxing Xu
0eb690390d
Add VisitCXXContructExpr logic to the analyzer. This still has not fully worked
...
since RemoveDeadBinding mistakenly remove the binding to CXXThisRegion.
llvm-svn: 98629
2010-03-16 13:14:16 +00:00
Ted Kremenek
1794ec4a30
Simplify assertion.
...
llvm-svn: 98176
2010-03-10 19:09:37 +00:00
Ted Kremenek
fe697ebaaf
Remove '#if 0' code. Lazy compound values have proven their worth.
...
llvm-svn: 98175
2010-03-10 19:09:34 +00:00
Ted Kremenek
9e92d3f99d
Remove the subregion map cache. It is no longer used.
...
llvm-svn: 98161
2010-03-10 16:38:44 +00:00
Ted Kremenek
2ce82b2323
Fix stale comment.
...
llvm-svn: 98160
2010-03-10 16:38:41 +00:00
Ted Kremenek
ddce4a3d0f
Really apply (unnoticed weird git-svn merge conflict in 98144): Refactor RegionStore::RemoveDeadBindings to use the same core cluster analysis algorithm as RegionStore::InvalidateRegions().
...
Beyond simplifying the algorithm significantly, we no longer
need to build subregion maps in RemoveDeadBindings(). This
and other changes cause a significant speedup: the time to
analyze sqlite3.c (single core) drops by 14%.
llvm-svn: 98159
2010-03-10 16:32:56 +00:00
Ted Kremenek
ba2e6c6b73
Refactor RegionStore::RemoveDeadBindings to use the same core
...
cluster analysis algorithm as RegionStore::InvalidateRegions().
Beyond simplifying the algorithm significantly, we no longer
need to build subregion maps in RemoveDeadBindings(). This
and other changes cause a significant speedup: the time to
analyze sqlite3.c (single core) drops by 14%.
llvm-svn: 98144
2010-03-10 07:20:03 +00:00
Ted Kremenek
a2536b642c
Refactor some of RegionStore's InvalidateRegionsWorker class
...
into a 'ClusterAnalysis' parent class. The idea is
to potentially reuse this for reworking RemoveDeadBindings.
llvm-svn: 98143
2010-03-10 07:19:59 +00:00
Zhongxing Xu
6d3cc382df
Since now we store the cast type with an ElementRegion, there is
...
no need to store a type with SymbolRegionValue.
llvm-svn: 97437
2010-03-01 06:56:52 +00:00
Zhongxing Xu
b0e5c27113
Assert when loading from a code text region instead of returning an unknown silently.
...
llvm-svn: 97436
2010-03-01 05:29:02 +00:00
Ted Kremenek
1a6672a3d4
Enhance RegionStore::InvalidateRegions() to correctly invalidate bindings
...
by scanning through the values of LazyCompoundVals.
llvm-svn: 96067
2010-02-13 01:52:33 +00:00
Ted Kremenek
7950b78430
Pull logic for visiting value bindings in InvalidateRegionsWorker into a separate method.
...
No functionality change.
llvm-svn: 96060
2010-02-13 00:54:03 +00:00
Douglas Gregor
0a5a2216e2
Eliminate the ASTContext parameter from RecordDecl::getDefinition()
...
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.
llvm-svn: 95836
2010-02-11 01:04:33 +00:00
Zhongxing Xu
bc1d4ae206
Add comment.
...
llvm-svn: 95755
2010-02-10 02:02:10 +00:00