summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/MemRegion.cpp
Commit message (Collapse)AuthorAgeFilesLines
* rename: MemRegion:Zhongxing Xu2009-05-091-8/+0
| | | | | | | | | RValueType => ObjectType LValueType => LocationType No functionality change. llvm-svn: 71304
* The super region of ElementRegion no longer needs to be TypedRegion. In theZhongxing Xu2009-05-061-1/+1
| | | | | | future we would create ElementRegion directly on top of typeless regions. llvm-svn: 71075
* Per conversations with Zhongxing, add an 'element type' toTed Kremenek2009-05-041-17/+8
| | | | | | | | | | | | | | | | | | | ElementRegion. I also removed 'ElementRegion::getArrayRegion', although we may need to add this back. This breaks a few test cases with RegionStore: - 'array-struct.c' triggers an infinite recursion in RegionStoreManager. Need to investigate. - misc-ps.m triggers a failure with RegionStoreManager as we now get the diagnostic: 'Line 159: Uninitialized or undefined return value returned to caller.' There were a bunch of places that needed to be edit RegionStoreManager, and we may not be passing all the correct 'element types' down from GRExprEngine. Zhongxing: When you get a chance, could you review this? I could have easily screwed up something basic in RegionStoreManager. llvm-svn: 70830
* MemRegion pretty-printing: Convert DeclName to a string to print out the actualTed Kremenek2009-04-291-1/+1
| | | | | | name of the tracked function. llvm-svn: 70381
* Recommit 69694 but this time also include the header changes (sorry for breakingTed Kremenek2009-04-211-0/+10
| | | | | | the build). llvm-svn: 69702
* Revert 69694 (use of undefined getSymbol)Daniel Dunbar2009-04-211-10/+0
| | | | llvm-svn: 69697
* Add pretty-printing for CodeTextRegions.Ted Kremenek2009-04-211-0/+10
| | | | llvm-svn: 69694
* Lexically order the implementation of MemRegion 'print' methods. No ↵Ted Kremenek2009-04-211-18/+18
| | | | | | functionality change. llvm-svn: 69688
* Implement analyzer support for OSCompareAndSwap. This required pushing "tagged"Ted Kremenek2009-04-111-1/+16
| | | | | | | | | 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. llvm-svn: 68845
* Add prototype for CodeTextRegion.Zhongxing Xu2009-04-101-0/+48
| | | | | | | | 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. llvm-svn: 68777
* Re-apply 68028. The code had drifted enough that the tests would fail withoutTed Kremenek2009-03-301-22/+0
| | | | | | it. Will discuss offline whether symbolic regions should by typed or typeless. llvm-svn: 68070
* Revert 68028.Ted Kremenek2009-03-301-0/+22
| | | | llvm-svn: 68068
* Make SymbolicRegion untyped.Zhongxing Xu2009-03-301-22/+0
| | | | | | Layer the type information with a TypedViewRegion on top of the SymbolicRegion. llvm-svn: 68028
* analyzer infrastructure: make a bunch of changes to symbolic expressions thatTed Kremenek2009-03-261-10/+4
| | | | | | | | | | | | | | | | 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. llvm-svn: 67731
* Add TypedViewRegion::isBoundable() to indicate whether or not theTed Kremenek2009-03-111-1/+1
| | | | | | | | | | | | | | | 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. llvm-svn: 66712
* MemRegion:Ted Kremenek2009-03-041-2/+3
| | | | | | | | | - 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). llvm-svn: 66093
* Added the notion of a "boundable region", which is a region that can have a ↵Ted Kremenek2009-03-041-6/+16
| | | | | | direct binding in the StoreManager. llvm-svn: 66005
* Rework use of loc::SymbolVal in the retain/release checker to use the new methodTed Kremenek2009-03-031-2/+1
| | | | | | | | | | | 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'. llvm-svn: 65972
* Rename AnonTypedRegion to TypedViewRegion.Ted Kremenek2009-03-011-9/+9
| | | | llvm-svn: 65764
* Create ElementRegion when the base is SymbolicRegion. This is like what we doZhongxing Xu2009-02-061-10/+6
| | | | | | | | | for FieldRegion. This enables us to track more values. Simplify SymbolicRegion::getRValueType(). We assume the symbol always has pointer type. llvm-svn: 63928
* Make SymbolicRegion subclass TypedRegion, for symbols usually have types, so Zhongxing Xu2009-02-051-6/+26
| | | | | | | | | | | | | | 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. llvm-svn: 63844
* Fix a couple bugs:Ted Kremenek2009-01-301-2/+3
| | | | | | | | | | | | | | - 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> llvm-svn: 63347
* Fix crash ElementRegion::getRValueType() when the RvalueType of the ↵Ted Kremenek2009-01-241-9/+6
| | | | | | ArrayRegion is a typedef and not (directly) a pointer. llvm-svn: 62909
* When getting the element region type, we should get the rvalue type of the superZhongxing Xu2009-01-231-2/+2
| | | | | | region. Otherwise we would get an extra level of pointer type. llvm-svn: 62844
* StringRegion::print: Remove copy/paste code and just call ↵Ted Kremenek2009-01-161-17/+1
| | | | | | Stmt::printPretty() for the StringLiteral. llvm-svn: 62340
* Add isSubRegionOf() method to SubRegion.Zhongxing Xu2009-01-081-0/+13
| | | | llvm-svn: 61924
* Lazy bingding for region-store manager.Zhongxing Xu2008-12-201-0/+14
| | | | | | | | | | | | | * 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. llvm-svn: 61274
* Add pretty-printing for AnonTypedRegion.Ted Kremenek2008-12-171-0/+6
| | | | llvm-svn: 61146
* MemRegion:Ted Kremenek2008-12-131-35/+11
| | | | | | | | | | | | | | | | | | | | | | - 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. llvm-svn: 60995
* A series of cleanups/fixes motivated by <rdar://problem/6442306>:Ted Kremenek2008-12-131-4/+4
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 60990
* Identify AnonPointeeRegion by the symbol that is concretized.Zhongxing Xu2008-12-111-10/+7
| | | | llvm-svn: 60870
* AnonPointeeRegions are now identified by the MemRegion of the pointer pointingZhongxing Xu2008-12-111-6/+6
| | | | | | to them. llvm-svn: 60868
* Add SymbolRef::print() and have SymbolicRegion::print() use this method ↵Ted Kremenek2008-12-051-1/+2
| | | | | | instead of calling SymbolRef::getNumber(). llvm-svn: 60578
* Use trait-based profiling of SymbolRefs, avoiding calling getNumber() (which ↵Ted Kremenek2008-12-051-1/+1
| | | | | | will soon be removed). llvm-svn: 60577
* Rename SymbolID to SymbolRef. This is a precursor to some overhauling of ↵Ted Kremenek2008-12-051-2/+2
| | | | | | the representation of symbolic values. llvm-svn: 60575
* Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of Chris Lattner2008-11-241-2/+2
| | | | | | | | | | | 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. llvm-svn: 59947
* Fold assertion into second valid else branch. This removes a compiler warningTed Kremenek2008-11-171-3/+2
| | | | | | | | 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. llvm-svn: 59468
* Enhances SCA to process untyped region to typed region conversion.Zhongxing Xu2008-11-161-1/+25
| | | | | | | | | | | | - 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. llvm-svn: 59382
* Change AllocaRegion to subclass TypedRegion. We need to know ElementRegion'sZhongxing Xu2008-11-131-2/+12
| | | | | | type when assigning to it. llvm-svn: 59229
* Fix StringLiteral print bug.Zhongxing Xu2008-11-111-1/+17
| | | | llvm-svn: 59015
* Add pretty printing to StringRegion.Zhongxing Xu2008-11-101-0/+4
| | | | llvm-svn: 58985
* - Remove AnonTypedRegion, which is not to be used.Zhongxing Xu2008-11-031-15/+9
| | | | | | - Prepare AnonPointeeRegioin for later use. llvm-svn: 58595
* Added AllocaRegion, which represents regions created by calls to alloca().Ted Kremenek2008-11-021-2/+35
| | | | llvm-svn: 58551
* Pull determination of the super region for a VarRegion into a single ↵Ted Kremenek2008-10-271-2/+5
| | | | | | getVarRegion() method. This provides a common clean API for clients. llvm-svn: 58272
* Added CompoundLiteralRegion to represent the (temporary) memory allocated ↵Ted Kremenek2008-10-271-0/+41
| | | | | | for a compound literal. llvm-svn: 58270
* An ElementRegion is really a typed region. Its super region's type has to be ↵Zhongxing Xu2008-10-271-0/+7
| | | | | | ArrayType. llvm-svn: 58245
* Add StringRegion to MemRegions.Zhongxing Xu2008-10-251-0/+27
| | | | llvm-svn: 58137
* Added region ObjCObjectRegion that represents an instance of an Objective-C ↵Ted Kremenek2008-10-241-0/+21
| | | | | | object. llvm-svn: 58106
* Add printing method to ElementRegion.Zhongxing Xu2008-10-241-0/+5
| | | | llvm-svn: 58077
* Add ElementRegion to represent memory chunks for array elements.Zhongxing Xu2008-10-211-0/+28
| | | | llvm-svn: 57891
OpenPOWER on IntegriCloud