aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/MemRegion.cpp
AgeCommit message (Collapse)Author
2009-04-29MemRegion pretty-printing: Convert DeclName to a string to print out the actualTed Kremenek
name of the tracked function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70381 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21Recommit 69694 but this time also include the header changes (sorry for breakingTed Kremenek
the build). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21Revert 69694 (use of undefined getSymbol)Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69697 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21Add pretty-printing for CodeTextRegions.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69694 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-21Lexically order the implementation of MemRegion 'print' methods. No ↵Ted Kremenek
functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69688 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-11Implement analyzer support for OSCompareAndSwap. This required pushing "tagged"Ted Kremenek
ProgramPoints all the way through to GRCoreEngine. NSString.m now fails with RegionStoreManager because of the void** cast. Disabling use of region store for that test for now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68845 91177308-0d34-0410-b5e6-96231b3b80d8
2009-04-10Add prototype for CodeTextRegion.Zhongxing Xu
A CodeTextRegion wraps two kinds of data: FunctionDecl* or SymbolRef. The latter comes from the symbolic function pointer that are generated from function calls or input data. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68777 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-30Re-apply 68028. The code had drifted enough that the tests would fail withoutTed Kremenek
it. Will discuss offline whether symbolic regions should by typed or typeless. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68070 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-30Revert 68028.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68068 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-30Make SymbolicRegion untyped.Zhongxing Xu
Layer the type information with a TypedViewRegion on top of the SymbolicRegion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68028 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-26analyzer infrastructure: make a bunch of changes to symbolic expressions thatTed Kremenek
Zhongxing and I discussed by email. Main changes: - Removed SymIntConstraintVal and SymIntConstraint - Added SymExpr as a parent class to SymbolData, SymSymExpr, SymIntExpr - Added nonloc::SymExprVal to wrap SymExpr - SymbolRef is now just a typedef of 'const SymbolData*' - Bunch of minor code cleanups in how some methods were invoked (no functionality change) This changes are part of a long-term plan to have full symbolic expression trees. This will be useful for lazily evaluating complicated expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67731 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-11Add TypedViewRegion::isBoundable() to indicate whether or not theTed Kremenek
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66712 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04MemRegion:Ted Kremenek
- Have 'TypedRegion::getRValueType()' return a null QualType for 'id<...>' instead of aborting. - Change 'TypedRegion::isBoundable()' to return true for all objects with a non-null RValueType (this may not be the final behavior). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66093 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-04Added the notion of a "boundable region", which is a region that can have a ↵Ted Kremenek
direct binding in the StoreManager. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66005 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-03Rework use of loc::SymbolVal in the retain/release checker to use the new methodTed Kremenek
SVal::getAsLocSymbol(). This simplifies the code and allows the retain/release checker to (I believe) also correctly reason about location symbols wrapped in SymbolicRegions. Along the way I cleaned up SymbolRef a little, disallowing implicit casts to 'unsigned'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65972 91177308-0d34-0410-b5e6-96231b3b80d8
2009-03-01Rename AnonTypedRegion to TypedViewRegion.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65764 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-06Create ElementRegion when the base is SymbolicRegion. This is like what we doZhongxing Xu
for FieldRegion. This enables us to track more values. Simplify SymbolicRegion::getRValueType(). We assume the symbol always has pointer type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63928 91177308-0d34-0410-b5e6-96231b3b80d8
2009-02-05Make SymbolicRegion subclass TypedRegion, for symbols usually have types, so Zhongxing Xu
do the symblic regions associated with them and we need them to be typed. Current SymbolicRegion::getRValueType() method is very restricting. It may be modified when we are more clear about what could be the types of symblic regions. BasicConstraintManager::Assume() is changed due to that now SymblicRegion is a subclass of SubRegion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63844 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-30Fix a couple bugs:Ted Kremenek
- NonLoc::MakeVal() would use sizeof(unsigned) (literally) instead of consulting ASTContext for the size (in bits) of 'int'. While it worked, it was a conflation of concepts and using ASTContext.IntTy is 100% correct. - RegionStore::getSizeInElements() no longer assumes that a VarRegion has the type "ConstantArray", and handles the case when uses use ordinary variables as if they were arrays. - Fixed ElementRegion::getRValueType() to just return the rvalue type of its "array region" in the case the array didn't have ArrayType. - All of this fixes <rdar://problem/6541136> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63347 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-24Fix crash ElementRegion::getRValueType() when the RvalueType of the ↵Ted Kremenek
ArrayRegion is a typedef and not (directly) a pointer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62909 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-23When getting the element region type, we should get the rvalue type of the superZhongxing Xu
region. Otherwise we would get an extra level of pointer type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62844 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-16StringRegion::print: Remove copy/paste code and just call ↵Ted Kremenek
Stmt::printPretty() for the StringLiteral. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62340 91177308-0d34-0410-b5e6-96231b3b80d8
2009-01-08Add isSubRegionOf() method to SubRegion.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61924 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-17Add pretty-printing for AnonTypedRegion.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61146 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-11Identify AnonPointeeRegion by the symbol that is concretized.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60870 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11AnonPointeeRegions are now identified by the MemRegion of the pointer pointingZhongxing Xu
to them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60868 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05Add SymbolRef::print() and have SymbolicRegion::print() use this method ↵Ted Kremenek
instead of calling SymbolRef::getNumber(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60578 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-05Use trait-based profiling of SymbolRefs, avoiding calling getNumber() (which ↵Ted Kremenek
will soon be removed). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60577 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-11-24Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of Chris Lattner
uses of getName() with uses of getDeclName(). This upgrades a bunch of diags to take DeclNames instead of std::strings. This also tweaks a couple of diagnostics to be cleaner and changes CheckInitializerTypes/PerformInitializationByConstructor to pass around DeclarationNames instead of std::strings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59947 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17Fold assertion into second valid else branch. This removes a compiler warningTed Kremenek
where the control reaches the end of a non-void function and also allows the compiler to generate better code. When this assertion is false we can easily add more else cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59468 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-13Change AllocaRegion to subclass TypedRegion. We need to know ElementRegion'sZhongxing Xu
type when assigning to it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59229 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11Fix StringLiteral print bug.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59015 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-10Add pretty printing to StringRegion.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58985 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-03- Remove AnonTypedRegion, which is not to be used.Zhongxing Xu
- Prepare AnonPointeeRegioin for later use. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58595 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-02Added AllocaRegion, which represents regions created by calls to alloca().Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58551 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27Pull determination of the super region for a VarRegion into a single ↵Ted Kremenek
getVarRegion() method. This provides a common clean API for clients. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58272 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27Added CompoundLiteralRegion to represent the (temporary) memory allocated ↵Ted Kremenek
for a compound literal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58270 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27An ElementRegion is really a typed region. Its super region's type has to be ↵Zhongxing Xu
ArrayType. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58245 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-25Add StringRegion to MemRegions.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58137 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24Added region ObjCObjectRegion that represents an instance of an Objective-C ↵Ted Kremenek
object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58106 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24Add printing method to ElementRegion.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58077 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-21Add ElementRegion to represent memory chunks for array elements.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57891 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17Add pretty-printing support for FieldRegions.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57724 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17- constify some uses of MemRegion* (MemRegion should be immutable).Ted Kremenek
- Added new region "SymbolicRegion", which maps symbol values to the region domain. - Enhanced BasicStore::getFieldLValue() to return a FieldRegion (using SymbolicRegion) - Added some utility methods to GRState for fetch svals from the store. - Fixed regression in CheckNSError (we weren't getting the value bound to the parameter) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57717 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-08This is the first step to implement a field-sensitive store model. Other ↵Zhongxing Xu
things are simplified: no heap shape assumption, no parameter alias assumption, etc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57285 91177308-0d34-0410-b5e6-96231b3b80d8