aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/RegionStore.cpp
AgeCommit message (Collapse)Author
2009-01-06Return UnknownVal in RegionStoreManager::getSizeInElements() for unsupported ↵Ted Kremenek
regions. This silences a warning when compiling Release-Asserts builds. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61818 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-24Add a bunch of comments and FIXMEs.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61419 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-24set region default value if there are not enough init values for array and ↵Zhongxing Xu
struct. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61418 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-24Comment and fixup GDM entries for RegionStore to use unique 'tag classes' to ↵Ted Kremenek
identify GDM entries. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61409 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-20Lazy bingding for region-store manager.Zhongxing Xu
* Now Bind() methods take and return GRState* because binding could also alter GDM. * No variables are initialized except those declared with initial values. * failed C test cases are due to bugs in RemoveDeadBindings(), which removes constraints that is still alive. This will be fixed in later patch. * default value of array and struct regions will be implemented in later patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61274 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-16Implement RegionStoreManager::Remove().Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61069 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-14I think we should getRValueType here. The lvaluetype of an array region is ↵Zhongxing Xu
'pointer to array'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61003 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-13MemRegion:Ted Kremenek
- 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-13A series of cleanups/fixes motivated by <rdar://problem/6442306>:Ted Kremenek
GRExprEngine (VisitCast): - When using StoreManager::CastRegion, always use the state and value it returns to generate the next node. Failure to do so means that region values returned that don't require the state to be modified will get ignored. MemRegion: - Tighten the interface for ElementRegion. Now ElementRegion can only be created with a super region that is a 'TypedRegion' instead of any MemRegion. Code in BasicStoreManager/RegionStoreManager already assumed this, but it would result in a dynamic assertion check (and crash) rather than just having the compiler forbid the construction of such regions. - Added ElementRegion::getArrayRegion() to return the 'typed version' of an ElementRegion's super region. - Removed bogus assertion in ElementRegion::getType() that assumed that the super region was an AnonTypedRegion. All that matters is that it is a TypedRegion, which is now true all the time by design. BasicStore: - Modified getLValueElement() to check if the 'array' region is a TypedRegion before creating an ElementRegion. This conforms to the updated interface for ElementRegion. RegionStore: - In ArrayToPointer() gracefully handle things we don't reason about, and only create an ElementRegion if the array region is indeed a TypedRegion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60990 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11Address some comments on the name lookup/DeclContext patch from ChrisDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60897 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11Unifies the name-lookup mechanisms used in various parts of the ASTDouglas Gregor
and separates lexical name lookup from qualified name lookup. In particular: * Make DeclContext the central data structure for storing and looking up declarations within existing declarations, e.g., members of structs/unions/classes, enumerators in C++0x enums, members of C++ namespaces, and (later) members of Objective-C interfaces/implementations. DeclContext uses a lazily-constructed data structure optimized for fast lookup (array for small contexts, hash table for larger contexts). * Implement C++ qualified name lookup in terms of lookup into DeclContext. * Implement C++ unqualified name lookup in terms of qualified+unqualified name lookup (since unqualified lookup is not purely lexical in C++!) * Limit the use of the chains of declarations stored in IdentifierInfo to those names declared lexically. * Eliminate CXXFieldDecl, collapsing its behavior into FieldDecl. (FieldDecl is now a ScopedDecl). * Make RecordDecl into a DeclContext and eliminates its Members/NumMembers fields (since one can just iterate through the DeclContext to get the fields). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60878 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05Rename SymbolID to SymbolRef. This is a precursor to some overhauling of ↵Ted Kremenek
the representation of symbolic values. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60575 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05StoreManager::Retrieve and StoreManager::RemoveDeadBindings now take a ↵Ted Kremenek
GRState* argument instead of a Store. This allows them to use the GDM for storing other data. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60570 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04Revamp RegionStoreManager::RemoveDeadBindings. This method now does a ↵Ted Kremenek
complete mark-and-sweep of the store, removing dead regions and recording the set of live and dead symbols appropriately. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60523 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-04Add comments.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60516 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-02Make RegionStoreManager::InitializeArray safe against array sizes that don't ↵Sebastian Redl
have pointer width. This may be the case on 64-bit systems. Whether that fact is a bug is a different question, but it's easy to cure the symptom. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60422 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-30Add support for initializing array with string literal.Zhongxing Xu
This fixes PR3127 http://llvm.org/bugs/show_bug.cgi?id=3127 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60280 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-29To be consistent, make the index of the ElementRegion always signed.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60248 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-28Fix a serious bug.Zhongxing Xu
When initialized, the index of the ElementRegion was unsigned. But the index value of the ArraySubscriptExpr is signed. This inconsistency caused the value of the array element retrieved to be UnknownVal despite it was initialized to symbolic. This is only a hack. Real fix of this problem is required. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60207 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-28Use std::make_pair instead of std::pair's ctor.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60205 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-27RegionViewMap factory is actually not used. All GDMs should use factories fromZhongxing Xu
GDMContext. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60150 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24Fix the fix of revision 59974. Now array-struct.c passes too.Sebastian Redl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59975 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24Fix crash of array bounds checking under 64-bit.Sebastian Redl
There might be other, similar bugs lurking there. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59974 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24Add support for AllocaRegion extent with GDM.Zhongxing Xu
One design problem that is emerging is the signed-ness problem during static analysis. Many unsigned value have to be converted into signed value because it partipates in operations with signed values. On the other hand, we cannot blindly make all values occuring in static analysis signed, because we do have cases where unsignedness is required, for example, integer overflow detection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59957 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24Strings are NULL terminated. So the region size should plus one.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59943 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24Add a comment about the signedness.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59932 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24Add getSize() support for StringRegion.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59930 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-23Clean up code by using utility methods.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59899 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22Remove debug code.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59870 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-22Initial support for checking out of bound memory access. Only support Zhongxing Xu
ConcreteInt index for now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59869 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19Add support for symbolicating global structs and arrays in ↵Zhongxing Xu
RegionStoreManager::getInitialStore(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59619 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19Fix warning about RegionStoreManager::Retrieve() not always returning a value.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59571 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18handle the case that the array element is of structure type when bind the ↵Zhongxing Xu
whole array to a single value (for example, UnknownVal, UndefinedVal). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59521 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16Enhance modularization: return a <state,loc> pair to let GRExprEngine modify theZhongxing Xu
environment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59407 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16Enhances SCA to process untyped region to typed region conversion.Zhongxing Xu
- RegionView and RegionViewMap is introduced to assist back-mapping from super region to subregions. - GDM is used to carry RegionView information. - AnonTypedRegion is added to represent a typed region introduced by pointer casting. Later AnonTypedRegion can be used in other similar cases, e.g., malloc()'ed region. - The specific conversion is delegated to store manager. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59382 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15Improve zero value generation.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59356 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13Process array base expression of any type.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59240 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13Array index might be unsigned. We have to generate a temporary signed value forZhongxing Xu
it to be evaluated by APSInt::operators. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59238 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13Incomplete struct pointer can be used as a function argument.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59235 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12StoreManager::BindDecl now takes an SVal* for the initialization value ↵Ted Kremenek
instead of an Expr* (which can be null). Lazy symbolication of conjured symbols is now the sole responsibility of GRExprEngine. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59151 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-10Implement RegionStoreManager::RemoveDeadBindings(). This prunes several ↵Zhongxing Xu
false warning caused by removal of symbolic constraints. Currently we just mark all symbols live. Further optimization for dead binding removal needed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58982 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-07Finish the implementation of VisitCompoundLiteralExpr. As VisitInitListExpr is Zhongxing Xu
available, things get much simplified. One addition is that CompoundLiteralExpr can appear both in rvalue and lvalue context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58837 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-07Make the assertion real.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58833 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-021. When a pointer to struct is used as an argument, GRSimpleVals::EvalCall()Zhongxing Xu
sets the whole struct to Unknown. Then we cannot assume the V passed to BindStruct() is always a CompoundVal. When it is an UnknownVal, we call BindStructToVal(UnknownVal). 2. Change the signature of InitializeStructToUndefined() to BindStructToVal() to reuse the code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58564 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31Simplify interface. We can get canonical type from the base region directly. ↵Zhongxing Xu
No need for an extra type argument. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58507 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31Implement struct initialization for SCA.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58506 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31Implement array initialization for SCA.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58504 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31Implement BindStruct and fix a bug in RetriveStruct.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58496 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31Implement load from struct region. Instead of returning an UnknownVal(), we ↵Zhongxing Xu
create a CompoundVal by loading from each field of the struct. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58494 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-29Rename: AddDecl => BindDeclZhongxing Xu
BindDecl better describes what the function does: - Bind the VarDecl to its memory region - Bind the memory region to some initial value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58359 91177308-0d34-0410-b5e6-96231b3b80d8