Commit Graph

48 Commits

Author SHA1 Message Date
Ted Kremenek 2c6a7b2776 Remove GRStateManager::GetSValAsScalarOrLoc()/GetSVal().
llvm-svn: 74128
2009-06-24 22:15:30 +00:00
Ted Kremenek 7df5691d2d Remove GRStateManager::BindLoc() and GRStateManager::Unbind().
llvm-svn: 73996
2009-06-23 20:38:51 +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 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 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 aa4cfc2604 analyzer: Introduce a new class, ValueManager, that serves as an aggregate
"manager of symbolic values", wrapping BasicValueFactory, SymbolManager, and
MemRegionManager. While these individual managers nicely separate functionality
in the analyzer, constructing symbolic values can sometimes be cumbersome
because it requires using multiple managers at once. The goal of this class is
to create some factory methods to create SVals that require the use of these
different managers, thus (hopefully) simplifying the analyzer API for clients.

llvm-svn: 68709
2009-04-09 16:13:17 +00:00
Ted Kremenek 248fd2bc24 Simplify more code by using SVal::getAsSymbol() instead of
loc::SymbolVal/nonloc::SymbolVal probing.

llvm-svn: 68049
2009-03-30 18:45:36 +00:00
Zhongxing Xu 7d41c616f1 Adjust indentation.
llvm-svn: 66022
2009-03-04 06:33:38 +00:00
Ted Kremenek 19df925f6b Add "GetSValAsScalarOrLoc" methods to GRState/GRStateRef that only perform a
retrieval from the store/environment for locations or scalar types.

llvm-svn: 65982
2009-03-04 00:13:10 +00:00
Ted Kremenek 9f276d6279 Don't use std::auto_ptr with getSubRegionMap().
llvm-svn: 65957
2009-03-03 19:02:42 +00:00
Ted Kremenek 5340b248b4 Fix extra ';' bug noticed by Mike Stump.
llvm-svn: 65954
2009-03-03 18:15:30 +00:00
Ted Kremenek 4c8a5817a5 Implement FIXME: GRStateManager::scanReachableSymbols now supports scanning MemRegions.
llvm-svn: 65919
2009-03-03 02:51:43 +00:00
Ted Kremenek 4e9d4b5d48 Added GRStateManager::scanReachableSymbols(), a method which scans the reachable
symbols from an SVal.

- Fixed a bug in EnvironmentManager::RemoveDeadBindings() where it did not mark
  live all the symbols reachable from a live block-level expression.

- Fixed a bug in the retain/release checker where it did not stop tracking
  symbols that 'escaped' via compound literals being assigned to something the
  BasicStoreManager didn't reason about.

llvm-svn: 64534
2009-02-14 03:16:10 +00:00
Ted Kremenek 16fbfe699e Static Analyzer: Replace LiveSymbols/DeadSymbols sets with a new object called "SymbolReaper". Right now it just consolidates the two and cleans up some client code, but shortly it will be used to enable "lazy computation" of live symbols for use with RegionStore.
llvm-svn: 62722
2009-01-21 22:26:05 +00:00
Zhongxing Xu af7415ffb1 Lazy bingding for region-store manager.
* 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
2008-12-20 06:32:12 +00:00
Ted Kremenek d8242f19f7 Rename SymbolID to SymbolRef. This is a precursor to some overhauling of the representation of symbolic values.
llvm-svn: 60575
2008-12-05 02:27:51 +00:00
Ted Kremenek d368de794a StoreManager::Retrieve and StoreManager::RemoveDeadBindings now take a GRState* argument instead of a Store. This allows them to use the GDM for storing other data.
llvm-svn: 60570
2008-12-05 00:47:52 +00:00
Ted Kremenek b94d72a0e3 GRStateRef:
- Rename SetSVal to BindLoc
- Add BindDecl
- Add BindExpr

GRState:
- Environment now binds to Stmt* instead of Expr*.  This is needed for processing ObjCForCollectionStmt (essentially the declaration of the the 'element' variable can have an SVal attached to it).
- BindDecl no longer accepts Expr* for the initialization value; use SVal* instead.

llvm-svn: 59152
2008-11-12 19:21:30 +00:00
Zhongxing Xu 2c677c34d5 Finish the implementation of VisitCompoundLiteralExpr. As VisitInitListExpr is
available, things get much simplified.

One addition is that CompoundLiteralExpr can appear both in rvalue and lvalue
context.

llvm-svn: 58837
2008-11-07 10:38:33 +00:00
Zhongxing Xu 8ea09cc542 Fix 80-col violations.
llvm-svn: 58596
2008-11-03 05:18:34 +00:00
Zhongxing Xu a15cfd4db9 Rename:
- SetSVal(GRState*, Loc, SVal) => BindLoc
 - SetSVal(GRState*, Expr*, SVal) => BindExpr 

llvm-svn: 58421
2008-10-30 05:33:54 +00:00
Zhongxing Xu 628ae879ea Rename: AddDecl => BindDecl
BindDecl better describes what the function does:
  - Bind the VarDecl to its memory region
  - Bind the memory region to some initial value.

llvm-svn: 58359
2008-10-29 02:34:02 +00:00
Ted Kremenek bf26368255 Added preliminary support for CompoundLiterals in the static analyzer:
- GRExprEngine::VisitCompoundLiteral...
   (1) visits the initializer list (generating ExplodedNodes)
   (2) creates a CompoundMemRegion for the literal
   (3) creates a new state with the bound literal values using
       GRStateManager::BindCompoundLiteral

- GRStateManager::BindCompoundLiteral simply calls 
  StoreManager::BindCompoundLiteral to get a new store and returns a persistent
  GRState with that store.

- BasicStore::BindCompoundLiteral simply returns the same store, as it
  doesn't handle field sensitivity
  
- RegionStore::BindCompoundLiteral currently fires an assert (pending discussion
  of how to best implement mappings for CompoundLiteralRegion).

llvm-svn: 58277
2008-10-27 21:54:31 +00:00
Zhongxing Xu 8f6855e642 Modify Store interface: GetSVal/SetSVal => Retrieve/Bind.
llvm-svn: 57896
2008-10-21 06:27:32 +00:00
Zhongxing Xu 27f174214d This patch did the following renaming. There should be no functional changes.
RVal => SVal
LVal => Loc
NonLVal => NonLoc
lval => loc
nonlval => nonloc

llvm-svn: 57671
2008-10-17 05:57:07 +00:00
Zhongxing Xu 232c7929a2 This is the first step to build a better evaluation model for GRExprEngine. A
new VisitLValue method is added to replace the old VisitLVal. The semantics
model becomes more explicit to separate rvalue evaluation from lvalue
evaluation.  

llvm-svn: 57627
2008-10-16 06:09:51 +00:00
Zhongxing Xu 8c9771bdf0 Remove redundant parameter and rename StMgr to StateMgr.
llvm-svn: 57107
2008-10-05 12:12:48 +00:00
Ted Kremenek 5ca90a244f This is a big patch, but the functionality change is small and the rest of the patch consists of deltas due to API changes.
This patch overhauls the "memory region" abstraction that was prototyped (but never really used) as part of the Store.h.  This patch adds MemRegion.h and MemRegion.cpp, which defines the class MemRegion and its subclasses.  This classes serve to define an abstract representation of memory, with regions being layered on other regions to to capture the relationships between fields and variables, variables and the address space they are allocated in, and so on.  

The main motivation of this patch is that key parts of the analyzer assumed that all value bindings were to VarDecls.  In the future this won't be the case, and this patch removes lval::DeclVal and replaces it with lval::MemRegionVal.  Now all pieces of the analyzer must reason about abstract memory blocks instead of just variables.

There should be no functionality change from this patch, but it opens the door for significant improvements to the analyzer such as field-sensitivity and object-sensitivity, both which were on hold until the memory abstraction got generalized.

The memory region abstraction also allows type-information to literally be affixed to a memory region.  This will allow the some now redundant logic to be removed from the retain/release checker.

llvm-svn: 57042
2008-10-04 05:50:14 +00:00
Ted Kremenek b42f482c91 Implement second part of PR 2600: NSError** parameter may be null, and should be checked before being dereferenced.
llvm-svn: 56318
2008-09-18 23:09:54 +00:00
Ted Kremenek 2d470fc0ba Patch by Csaba Hruska!
"Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch
covers the AST library, but ignores Analysis lib."

llvm-svn: 56185
2008-09-13 05:16:45 +00:00
Zhongxing Xu c1bd3a5f8b Migrate the rest symbolic analysis stuff to BasicConstraintManager.
llvm-svn: 55536
2008-08-29 14:52:36 +00:00
Ted Kremenek b5ef37f28e Make the destructor of ConstraintManager virtual.
llvm-svn: 55448
2008-08-27 23:13:01 +00:00
Zhongxing Xu f71b5f39bb Refactor Assume logic into a separate class ConstraintManager.
llvm-svn: 55412
2008-08-27 14:03:33 +00:00
Chris Lattner a2e25e5e72 adjust to changes in various APIs from LLVM. We can't print
an APInt directly to an ostream now, so add some hacks.  It would
be better to switch all of the bugreport (and friends) stuff over
to raw_ostream.

llvm-svn: 55264
2008-08-23 22:23:37 +00:00
Ted Kremenek 4e7713c04d Simplify interface to Store::AddDecl
llvm-svn: 55213
2008-08-23 00:50:55 +00:00
Zhongxing Xu d95495f601 Move the handling of DeclStmt from GRExprEngine to BasicStoreManager.
llvm-svn: 55144
2008-08-21 22:34:01 +00:00
Ted Kremenek e5edbdd4ee Patch by Zhongxing Xu:
This patch moves some code in GRStateManager::RemoveDeadBindings() to EnvironmentManager::RemoveDeadBindings().

llvm-svn: 55064
2008-08-20 17:08:29 +00:00
Ted Kremenek eb38fde5e5 Patch by Zhongxing Xu: We should set back the modified ConstEq map.
llvm-svn: 55060
2008-08-20 16:59:15 +00:00
Ted Kremenek 19edd216f2 Move store pretty-printing logic inside of StoreManager (previously in GRState).
llvm-svn: 55013
2008-08-19 22:24:03 +00:00
Ted Kremenek 67102b281e Patch by Zhongxing Xu!
This patch extends BasicStoreManager::getInitialStore() to include code that symbolicates input variables.
It also removes redundant handling of ImplicitParamDecl, since it is a subclass of VarDecl.

llvm-svn: 54993
2008-08-19 16:51:45 +00:00
Chris Lattner 5d1cfa1229 various updates to match r54873 on mainline.
llvm-svn: 54874
2008-08-17 07:19:51 +00:00
Ted Kremenek 90d488f724 Migrate GRState::ConstEqTy (map used from tracking constants for symbols) to use the generic data map instead.
llvm-svn: 54860
2008-08-17 03:10:22 +00:00
Ted Kremenek edd9a18050 Added GRStateTrait.h, which includes boilerplate code for creating specializations of GRStateTrait<>.
Modified GRStateTrait<ConstNotEq> in GRState to use the boilerplate in GRStateTrait<> for ImmutableMaps.

llvm-svn: 54859
2008-08-17 02:59:30 +00:00
Ted Kremenek ceba6ead45 GRState:
- Remove ConstNotEq from GRState/GRStateManager (!= tracking uses GDM instead).
- GRStateManager now can book-keep "contexts" (e.g., factory objects) for uses
  with data elements stored into the GDM.
- Refactor pretty-printing of states to use GRState::Printer objects
  exclusively. This removed a huge amount of pretty-printing logic from
  GRExprEngine.

CFRefCount
- Simplified some API calls based on refinements to the GDM api.

llvm-svn: 54835
2008-08-16 00:49:49 +00:00
Ted Kremenek db7dd9cd15 Migrated retain/release checker to use the Generic Data Map in GRState (instead
of using CheckerState).

Removed CheckerState from GRState.

Added class GRStateRef which wraps GRState* and GRStateManager*. This is handy
for generating new states with a single handle.

Added member template set/get functions to GRStateRef/GRState/GRStateManager for
accessing the Generic Data Map.

llvm-svn: 54788
2008-08-14 21:16:54 +00:00
Ted Kremenek 16306107cf Renamed GRState::CheckerStatePrinter to GRState::Printer.
Updated checker state printer interface to allow transfer functions to return an arbitrary number of GRState::Printers.

llvm-svn: 54762
2008-08-13 21:24:49 +00:00
Ted Kremenek 0e7d96c370 Rename ValueState.h -> GRState.h
Rename ValueState.cpp -> GRState.cpp

llvm-svn: 54722
2008-08-13 04:28:02 +00:00