Commit Graph

1195 Commits

Author SHA1 Message Date
Ted Kremenek 4ac764d72e Remove orphaned header file.
llvm-svn: 74231
2009-06-26 00:08:20 +00:00
Ted Kremenek 1642bdaaa5 Introduce a new concept to the static analyzer: SValuator.
GRTransferFuncs had the conflated role of both constructing SVals (symbolic
expressions) as well as handling checker-specific logic. Now SValuator has the
role of constructing SVals from expressions and GRTransferFuncs just handles
checker-specific logic. The motivation is by separating these two concepts we
will be able to much more easily create richer constraint-generating logic
without coupling it to the main checker transfer function logic.

We now have one implementation of SValuator: SimpleSValuator.

SimpleSValuator is essentially the SVal-related logic that was in GRSimpleVals
(which is removed in this patch). This includes the logic for EvalBinOp,
EvalCast, etc. Because SValuator has a narrower role than the old
GRTransferFuncs, the interfaces are much simpler, and so is the implementation
of SimpleSValuator compared to GRSimpleVals. I also did a line-by-line review of
SVal-related logic in GRSimpleVals and cleaned it up while moving it over to
SimpleSValuator.

As a consequence of removing GRSimpleVals, there is no longer a
'-checker-simple' option. The '-checker-cfref' did everything that option did
but also ran the retain/release checker. Of course a user may not always wish to
run the retain/release checker, nor do we wish core analysis logic buried in the
checker-specific logic. The next step is to refactor the logic in CFRefCount.cpp
to separate out these pieces into the core analysis engine.

llvm-svn: 74229
2009-06-26 00:05:51 +00:00
Ted Kremenek 9ffbd9fb64 Remove declaration for unused and unimplemented static method.
llvm-svn: 74182
2009-06-25 17:25:49 +00:00
Zhongxing Xu c53b444d36 remove RegionKills GDM. Now UnknownVal is bound to regions explicitly.
llvm-svn: 74168
2009-06-25 05:52:16 +00:00
Zhongxing Xu 2d16073b50 Move element region retrieving logic into a separate function.
llvm-svn: 74166
2009-06-25 05:29:39 +00:00
Zhongxing Xu e67ea5c784 Move all logic for retrieving ElementRegion binding into a separate method.
Revert to setting default value approach for handling struct initialization.

llvm-svn: 74160
2009-06-25 04:50:44 +00:00
Ted Kremenek 799bb6e178 Remove uses of std::ostream from libAnalysis.
llvm-svn: 74136
2009-06-24 23:06:47 +00:00
Ted Kremenek 2c6a7b2776 Remove GRStateManager::GetSValAsScalarOrLoc()/GetSVal().
llvm-svn: 74128
2009-06-24 22:15:30 +00:00
Owen Anderson 4d9e93c420 Update for LLVM API changes.
llvm-svn: 74085
2009-06-24 17:37:55 +00:00
Zhongxing Xu 33420090ae use a concrete type instead of a trait type to make code more readable.
llvm-svn: 74047
2009-06-24 01:12:41 +00:00
Zhongxing Xu 9ef415edf2 RegionStore: revert to the default value approach for array initialization.
llvm-svn: 74043
2009-06-24 00:56:31 +00:00
Ted Kremenek 8cf2021012 Remove GRStateManager::getRegion/getSelfRegion().
llvm-svn: 74006
2009-06-23 21:37:46 +00:00
Ted Kremenek 7df5691d2d Remove GRStateManager::BindLoc() and GRStateManager::Unbind().
llvm-svn: 73996
2009-06-23 20:38:51 +00:00
Ted Kremenek 59ee3f5079 Remove GRStateManager::BindDecl() and GRStateManager::BindDeclWithInit().
llvm-svn: 73995
2009-06-23 20:27:53 +00:00
Ted Kremenek 2d99f97c17 - Add MemRegion::getMemorySpace()
- Change implementation of MemRegion::hasStackStorage()/hasHeapStorage() to use
  'getMemorySpace()'.  This avoids a double traversal up the region hierarchy
  and is simpler.
- Add MemRegion::hasHeapOrStackStorage() as a slightly more efficient
  alternative to 'hasStackStorage() || hasHeapStorage()'.

llvm-svn: 73977
2009-06-23 18:17:08 +00:00
Ted Kremenek 404b132dc0 Move 'hasStackStorage()' and 'hasHeapStorage()' from MemRegionManager to MemRegion.
llvm-svn: 73973
2009-06-23 18:05:21 +00:00
Ted Kremenek ae01dc73af API cleanup: move more methods from GRStateManager to GRState.
llvm-svn: 73968
2009-06-23 17:55:07 +00:00
Ted Kremenek d363f44c69 Update CMake file.
llvm-svn: 73958
2009-06-23 16:54:53 +00:00
Zhongxing Xu 7718ae4701 Move all factory methods from SVal to ValueManager. API cleanup!
llvm-svn: 73954
2009-06-23 09:02:15 +00:00
Zhongxing Xu 0808f70912 Split ValueManager method definitions into its own source file.
No functionality change.

llvm-svn: 73952
2009-06-23 06:22:22 +00:00
Zhongxing Xu d09b5205ef ValueManager::makeNonLoc -> ValueManager::makeIntVal
Clean up code with ValueManager.

llvm-svn: 73951
2009-06-23 06:13:19 +00:00
Zhongxing Xu 0442e962d9 If the init list is fewer than the struct fields, bind the rest fields to 0
explicitly. Make 0 value with the field type.

llvm-svn: 73949
2009-06-23 05:43:16 +00:00
Zhongxing Xu b7cf95957d Instead of setting the default value of the array region, bind the rest of the
array elements to 0 explicitly. Create 0 values with the element type.

llvm-svn: 73946
2009-06-23 05:23:38 +00:00
Zhongxing Xu cbfc7d6c2e MemRegionManager: Migrate logic for getCodeTextRegion() over to using
trait-based MemRegion creation.

llvm-svn: 73941
2009-06-23 03:50:30 +00:00
Zhongxing Xu 1a195b264f Remove duplicated methods.
llvm-svn: 73940
2009-06-23 02:51:21 +00:00
Zhongxing Xu 74fa0bc3de add a fixme.
llvm-svn: 73939
2009-06-23 02:08:56 +00:00
Ted Kremenek fb87e30815 MemRegions:
- Embed a reference to MemRegionManager objects in MemSpaceRegion objects
- Use this embedded reference for MemRegion objects to access ASTContext objects without external help
- Use this access to ASTContext to simplify 'isBoundable' (no ASTContext& argument required)

llvm-svn: 73935
2009-06-23 00:46:41 +00:00
Ted Kremenek 8bae300ade MemRegionManager: Migrate logic for getAllocaRegion() over to using trait-based MemRegion creation.
llvm-svn: 73927
2009-06-23 00:15:41 +00:00
Ted Kremenek 2266640a7a MemRegionManager: Migrate getObjCObjectRegion() and getTypedViewRegion() to use
the new trait-based construction of MemRegion objects.

llvm-svn: 73926
2009-06-23 00:04:09 +00:00
Ted Kremenek 214cdfea84 Migrate factory methods for FieldRegion and ObjCIVarRegion creation to use the
new generalized region-construction code.

llvm-svn: 73921
2009-06-22 23:34:21 +00:00
Ted Kremenek e5e8b0b09b Refactor some of the logic in MemRegionManager for constructing regions using
member template functions and traits. The idea is to allow MemRegionManager to
construct subclasses of MemRegion that aren't declared in MemRegion.h (e.g.,
checker-specific regions).

llvm-svn: 73917
2009-06-22 23:13:13 +00:00
Zhongxing Xu 8077d7eb15 Allow CodeTextRegion to be cast to 'void *'.
llvm-svn: 73880
2009-06-22 08:36:10 +00:00
Zhongxing Xu 540c009fbe Return UnknownVal for pointer arithmetic on struct fields.
llvm-svn: 73851
2009-06-21 13:24:24 +00:00
Ted Kremenek c55f0cdaa0 Remove more GetSVal/GetLValue methods in GRExprEngine/GRState, instead
preferring to use their replacements in GRState. This further unifies the code
paths for such logic and leads to some code reduction.

llvm-svn: 73771
2009-06-19 17:10:32 +00:00
Zhongxing Xu 54fb536b5c A further step of r73690: associate the cast-to type with the created symbol,
because the type of the symbol is used to create the default range. We need the
sign to be consistent.

llvm-svn: 73756
2009-06-19 06:00:32 +00:00
Zhongxing Xu cc45762253 If the SymbolicRegion was cast to another type, use that type to create the
ElementRegion.

llvm-svn: 73754
2009-06-19 04:51:14 +00:00
Ted Kremenek 095f1a9848 Move clients over from using GRStateManager::BindXXX and friends to
GRState->bindXXX and friends (and constify some arguments along the way).

llvm-svn: 73740
2009-06-18 23:58:37 +00:00
Ted Kremenek 4c6a367182 Remove GRStateManager& field from SimpleConstraintManager.
llvm-svn: 73735
2009-06-18 23:20:05 +00:00
Ted Kremenek f9906843b7 libAnalysis:
- Remove the 'isFeasible' flag from all uses of 'Assume'.
- Remove the 'Assume' methods from GRStateManager.  Now the only way to
  create a new GRState with an assumption is to use the new 'assume' methods
  in GRState.

llvm-svn: 73731
2009-06-18 22:57:13 +00:00
Douglas Gregor 78bd61f661 Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
llvm-svn: 73702
2009-06-18 16:11:24 +00:00
Zhongxing Xu cea6578078 When casting region, if we do not create an element region, record the cast-to
type. 

When retrieving the region value, if we are going to create a symbol value, use
the cast-to type if possible.

llvm-svn: 73690
2009-06-18 06:29:10 +00:00
Ted Kremenek 6a667ab710 Remove GRStateRef.
llvm-svn: 73670
2009-06-18 01:33:24 +00:00
Ted Kremenek d93c6e3fd6 Remove more dependencies on GRStateRef. As a consequence, we can now
pretty-print a GRState object anywhere it is referenced (instead of
needing a GRStateRef of a GRStateManager handy).

llvm-svn: 73669
2009-06-18 01:23:53 +00:00
Ted Kremenek 89a303caac Remove another dependency on GRStateRef.
llvm-svn: 73667
2009-06-18 00:49:02 +00:00
Steve Naroff fb4330f255 First step toward fixing <rdar://problem/6613046> refactor clang objc type representation.
Add a type (ObjCObjectPointerType) and remove a type (ObjCQualifiedIdType).

This large/tedious patch is just a first step. Next step is to remove ObjCQualifiedInterfaceType. After that, I will remove the magic TypedefType for 'id' (installed by Sema). This work will enable various simplifications throughout clang (when dealing with ObjC types). 

No functionality change.

llvm-svn: 73649
2009-06-17 22:40:22 +00:00
Ted Kremenek b35e2caab5 Remove more uses of GRStateRef.
llvm-svn: 73648
2009-06-17 22:28:13 +00:00
Ted Kremenek 609df30929 Start moving in the direction of removing GRStateRef. Now each
GRState object has a direct reference to its GRStateManager, making
the functionality of GRStateRef redunandant.  This will lead to some
nice API cleanup and code shrinking across libAnalysis.

llvm-svn: 73644
2009-06-17 22:02:04 +00:00
Ted Kremenek 4533a55696 RegionStoreManager:
- Add "sections" to RegionStoreManager.cpp to delineate functionality.
- Add new function "CreateFieldsOnlyRegionStoreManager" that uses the new
  RegionStoreFeatures class to use a reduced set of features from
  RegionStoreManager (in this case, only field-sensitivity). This isn't
  completely hooked up yet.

llvm-svn: 73572
2009-06-16 22:36:44 +00:00
Zhongxing Xu 838a0db0ba Use canonical type for building ElementRegion. Otherwise ElementRegions cannot
be unique.

llvm-svn: 73482
2009-06-16 09:55:50 +00:00
Zhongxing Xu e531f048f8 Do not invalidate unboundable regions in GRSimpleVals::EvalCall().
llvm-svn: 73474
2009-06-16 06:18:21 +00:00