Commit Graph

267 Commits

Author SHA1 Message Date
Ted Kremenek b2652827e6 Modified state pretty-printing to include the '!=' and '==' constraints on
symbols (for constant integers).

llvm-svn: 46795
2008-02-06 03:56:15 +00:00
Ted Kremenek 0ea8fea0ba Disabled operator= for ValueStateImpl.
ValueState no longer inherits FoldingSetNode (not needed).
Removed redundant operator= implementation for ValueState (it simply did the default behavior).

llvm-svn: 46794
2008-02-06 02:50:36 +00:00
Ted Kremenek 4ff4e7ce9f Fixed bug when allocating a ValueStateImpl object in getPersistentState()
using the bump-pointer allocator and a placed new; we accidentally allocated
a ValueStateImpl* instead, causing an overrun when we did a placed new().

llvm-svn: 46793
2008-02-06 02:45:20 +00:00
Ted Kremenek 03e7b55f22 Added some skeleton code for performing "assume" on symbols: e.g. assume($0 != 0).
This action will add constraints to the possible values of a symbol.
Still needs to be debugged.

llvm-svn: 46789
2008-02-06 00:54:14 +00:00
Ted Kremenek 38b32e976c Added pretty-printing support for lval::SymIntConstraintVal and
nonlval::SymIntConstraintVal.

Reworked transfer function for '==' and '!=' for LValues to return
SymIntConstraintVal when comparing a symbol with a constant.

llvm-svn: 46778
2008-02-05 23:08:41 +00:00
Ted Kremenek 8f6dcfaa30 Moved implementation of cast<> for SymbolData closer to SymbolData's definition.
llvm-svn: 46772
2008-02-05 22:21:54 +00:00
Ted Kremenek 1ee50cd9c1 Added new "NonLValue" class: SymIntConstraintVal. This class represents a binary
contraint between a symbol and an integer constant.

llvm-svn: 46771
2008-02-05 22:10:48 +00:00
Ted Kremenek 1e3fa134de Moved subclasses of LValue and NonLValue into their own namespaces.
This noticeably cleans up the naming of these classes.

llvm-svn: 46770
2008-02-05 21:52:21 +00:00
Ted Kremenek a4aa95bd9d Added "SymIntConstraint", a utility class to represent intermediate values for
transfer function evaluation that represent constraints between symbolic values
and constant integers.

llvm-svn: 46769
2008-02-05 21:32:43 +00:00
Ted Kremenek e1bbf8e549 Added "batch" processing versions of Nodify and SetValue. Created typedefs
for buffers for RValues and States.

llvm-svn: 46759
2008-02-05 19:35:18 +00:00
Ted Kremenek 1cc95f6cd3 Added a "ConstantNotEq" map to ValueState (and added necessary typedefs and factory objects to ValueStateManager).
llvm-svn: 46758
2008-02-05 18:51:06 +00:00
Ted Kremenek 961ec7bc22 Added some comments.
llvm-svn: 46756
2008-02-05 18:24:17 +00:00
Ted Kremenek db814b5415 Renamed typedef "iterator" in ValueState to "vb_iterator" (for "VariableBindings").
llvm-svn: 46755
2008-02-05 18:19:15 +00:00
Ted Kremenek 17e5b5c99e Reordered fields/methods in ValueState to make it more aesthetically pleasing.
llvm-svn: 46754
2008-02-05 18:17:58 +00:00
Ted Kremenek d8902e06ba Overhauling of "ValueState" so that it represents its own functional data
structure that can contain several maps, not just one.

llvm-svn: 46744
2008-02-05 07:17:49 +00:00
Ted Kremenek 0a04690fda ValueManager now uses the BumpPtrAllocator owned by the ExplodedGraph.
llvm-svn: 46740
2008-02-05 05:15:51 +00:00
Ted Kremenek 4894c56ba7 Simplified transfer functions for '++' and '--'
llvm-svn: 46732
2008-02-05 00:43:43 +00:00
Ted Kremenek 3f2f1ade4c Implemented initial transfer function support for '&&', '||', '?', and
__builtin_choose.

llvm-svn: 46731
2008-02-05 00:26:40 +00:00
Ted Kremenek 7746a6279b Added file that should have been in my previous commit.
llvm-svn: 46722
2008-02-04 21:59:22 +00:00
Ted Kremenek 723fe3f863 Created ValueStateManager, a full-blown class to manage the states
created for GRConstants.  Moved instances of ValueManager and SymbolManager
inside this class.  The goal is to gradually separate more of the state
management from the state transformation.

llvm-svn: 46721
2008-02-04 21:59:01 +00:00
Ted Kremenek 2cdfd6670e Implemented transfer function for unary '~'.
llvm-svn: 46708
2008-02-04 16:58:30 +00:00
Ted Kremenek effdafa62a Implemented casts for ConcreteInt and ConcreteIntLValue.
Implemented '==' and '!=' for ConcreteIntLValue.

llvm-svn: 46630
2008-02-01 06:36:40 +00:00
Ted Kremenek 2820b9c893 Added skeleton for new LValue class ConcereteIntLValue.
llvm-svn: 46624
2008-01-31 22:17:03 +00:00
Ted Kremenek 2838799859 Moved RValue code in GRConstants.cpp to RValue.[h,cpp].
Moved ValueKey/ValueMap declaration to ValueState.h.

llvm-svn: 46618
2008-01-31 19:34:24 +00:00
Ted Kremenek 6f4a9ef4b6 Fixed misspelling of "LLVM" due to some editor+Ted madness.
llvm-svn: 46604
2008-01-31 06:49:09 +00:00
Ted Kremenek a0be8264b5 Added transfer function support for unary '&' and '*', providing basic
(local) aliasing support.

Modified ExplodedGraph pretty-printer (for GRConstants) to also print out the
pointer value of the state associated with a node.  This way one can easily
see that two states are identical.

llvm-svn: 46595
2008-01-31 02:35:41 +00:00
Ted Kremenek b5474fc529 Added 'SymbolicLValue' class to represent LValues whose value is symbolic.
Improved pretty-printing of LValues.
Parameters whose values are pointers/references are now assigned SymbolicLValues.

llvm-svn: 46584
2008-01-31 00:09:56 +00:00
Ted Kremenek 2531fce319 We now delay adding nodes created by GRBranchNodeBuilder to the analysis
worklist until the dstor of GRBranchNodeBuilderImpl. This way clients can mark
creates nodes as "sinks" before they are added to the worklist.

llvm-svn: 46582
2008-01-30 23:24:39 +00:00
Ted Kremenek a50d98565f Implemented some branch pruning in GRConstants using != and == for
constant integers.

llvm-svn: 46581
2008-01-30 23:03:39 +00:00
Ted Kremenek 90962af0e8 Minor cosmetic cleanups: replaced some integer literals with constants and
more cleanups with pretty-printing of analysis results.

llvm-svn: 46564
2008-01-30 18:54:06 +00:00
Ted Kremenek 7ff1893f86 Implemented more boilerplate in GREngine for processing branches. Now
we automatically generate a new successor node along an edge if the checker
did not explicitly do so (i.e., we just propagate the current state).

llvm-svn: 46536
2008-01-29 23:32:35 +00:00
Ted Kremenek ee2d5a540c Fixed bit-setting bug for ExplodedNodeImpl::NodeGroup.
llvm-svn: 46535
2008-01-29 23:31:09 +00:00
Ted Kremenek 9b4211d25d Added boilerplate logic in GREngine for processing branches.
llvm-svn: 46532
2008-01-29 22:56:11 +00:00
Ted Kremenek b2cad31aae Renamed GRNodeBuilder to GRStmtNodeBuilder.
llvm-svn: 46531
2008-01-29 22:11:49 +00:00
Ted Kremenek 71b49503d8 Minor fix in transfer function of '!=' where a 'false' literal should
have been 'true'.

llvm-svn: 46530
2008-01-29 21:27:49 +00:00
Ted Kremenek 8d5bfe5844 Added preliminary transfer function support for '==' and '!='.
Made some internal API cleanups with creating ConcreteInt values, which lead to
some code reduction in implementing "++", "--".

llvm-svn: 46528
2008-01-29 19:43:15 +00:00
Ted Kremenek b6056cfea4 Added "SymbolManager", which manages the set of symbolic values used
for analyzing a function.

The initial state for GRConstants now assigns symbolic values to parameters.

llvm-svn: 46517
2008-01-29 17:27:31 +00:00
Ted Kremenek 75bc4cd620 Fixed bug where not all dead subexpressions were being pruned from the analysis
state.

llvm-svn: 46491
2008-01-29 05:25:31 +00:00
Ted Kremenek 8ff7705a6c Modified LiveVariables to perform all of its base initialization in the ctor,
and now we require a FunctionDecl* object so that we can also keep track of
all of the ParmDecls.

Modified clients of LiveVariables to conform to the new interface.

llvm-svn: 46490
2008-01-29 05:13:23 +00:00
Ted Kremenek e3d965f4b1 Added skeleton code for tracking the values of function parameters.
llvm-svn: 46477
2008-01-29 00:43:03 +00:00
Ted Kremenek 997d872375 Driver now passes the top-level FunctionDecl* to GRConstants.
Refactoring: for GREngine and GRConstants, pushed references to CFG, ASTContext,
and the top-level FunctionDecl into ExplodedGraphImpl.

llvm-svn: 46475
2008-01-29 00:33:40 +00:00
Ted Kremenek 64d9524dcb Added RValue class "UninitializedValue".
llvm-svn: 46471
2008-01-28 22:51:57 +00:00
Ted Kremenek fe9cf4f38b Added transfer function logic for "%=" operator.
llvm-svn: 46470
2008-01-28 22:28:54 +00:00
Ted Kremenek 7e67036f2f Added transfer function hookups for "modulo" operator.
llvm-svn: 46468
2008-01-28 22:26:15 +00:00
Ted Kremenek 5b8cd80897 Minor tweaking with hierarchy of NonLValue objects: SymbolValue is
now SymbolicNonLValue.

Cleaned up some casts.

llvm-svn: 46467
2008-01-28 22:25:21 +00:00
Ted Kremenek 17a739681c Some additional cleanups with method names.
Renamed ExprValue to RValue, as all expression values are RValues, and this
keeps with the C terminology (renamed old "RValue" class to "NonLValue").

Introduced "ConcreteInt", a class that represents a concrete, integer
constant as an RValue.

Temporarily removed classes to represent set of possible constants and set of !=
constants. Will replace with a more general class representing a set of
constraints.

Added some foundational code to track "symbolic" values, which are used to
accrue constraints on an abstract value that is shared between multiple
variables.  e.g:

   x = y;      // at this point "x" and "y" share the same "value"
   if (x > 1) 
     ...       // at this point, the value shared by "x" and "y" is "> 1".

llvm-svn: 46466
2008-01-28 22:09:13 +00:00
Ted Kremenek 95a123c0ec Added back logic in patch r46361 (http://llvm.org/viewvc/llvm-project?rev=46361&view=rev) with the addition of
some previously missing NULL pointer checks.

Modified the UninitializedValues analysis to not expect that every Expr* at the
block-level is a block-level expression (we probably need to change the name of
such expressions to something truer to their meaning).

llvm-svn: 46380
2008-01-26 00:03:27 +00:00
Ted Kremenek 5588c9e9ce Implemented transfer function for '/='.
llvm-svn: 46379
2008-01-25 23:45:34 +00:00
Ted Kremenek 2b8a7c80b8 Further refactoring of transfer functions by having APSIntSetOp take
a template-template parameter.

llvm-svn: 46378
2008-01-25 23:43:12 +00:00
Ted Kremenek ec5a444de6 Renamed RValueDisjunctiveEqual to RValEqualityORSet.
Renamed RValueConjunctiveUnequal to RValInequalityANDSet.

Refactored add/subtract/multiple (and now divide) operations for
RValEqualityORSet to be based on a single template function.

llvm-svn: 46374
2008-01-25 22:55:56 +00:00
Ted Kremenek 109e362fbd Fixed 80 col. violation.
llvm-svn: 46370
2008-01-25 22:07:26 +00:00
Ted Kremenek 555855c779 Renamed RValueMayEqualSet to RValueDisjunctiveEqual.
llvm-svn: 46368
2008-01-25 22:06:07 +00:00
Ted Kremenek 8a025806a4 Some minor restructuring around LValue and RValue types. The value "kind"
information is not separated into a "base" and "sub" type. Eventually the
value-tracking logic will know about LValues and RValues, but not about
specialized LValues and RValues; separating the "kind" information into bits
indicating whether an ExprValue is an LValue or an RValue from the bits that
specify the actual value type makes this separation easier.

llvm-svn: 46329
2008-01-24 23:19:54 +00:00
Ted Kremenek f3d6d668b6 enum value name change.
llvm-svn: 46327
2008-01-24 22:44:24 +00:00
Ted Kremenek 3e742f9184 More cleanups to pretty-printing of states in GraphViz output.
llvm-svn: 46326
2008-01-24 22:27:20 +00:00
Ted Kremenek 053527478b Added transfer function for DeclStmt.
llvm-svn: 46323
2008-01-24 20:55:43 +00:00
Ted Kremenek 1fba169ce0 Adjusted storage of values for Stmt* so that we need only query if
a Stmt* is a block-level expression when we INSERT a value into the map, and
not also when we QUERY a value.

llvm-svn: 46321
2008-01-24 19:43:37 +00:00
Ted Kremenek fa8062c162 Fixed a bug where the values of block-level expressions were being recorded in
the value map as if the expressions were non-block-level expressions.

llvm-svn: 46319
2008-01-24 19:28:01 +00:00
Ted Kremenek 286f030911 Minor tweaks in the transfer functions for pre- and post- ++/-- where
we falsely constructed an APInt to represent the constant '1' instead of
using an APSInt (which has a sign).

llvm-svn: 46317
2008-01-24 19:00:57 +00:00
Ted Kremenek c9052ff8fd Added support for unary operator '-' for equality sets.
Added some workarounds for loss of signess information on some APSInt
operations. Considering the best route to integrate these into APSInt directly.
(FIXME's in GRConstants.cpp).

llvm-svn: 46310
2008-01-24 08:20:02 +00:00
Ted Kremenek 1c91a67086 Added transfer functions for pre- and post- increment/decrement operators.
llvm-svn: 46300
2008-01-24 02:28:56 +00:00
Ted Kremenek 33d8285b8d Added passing "ASTContext" to both GREngine and GRConstants.
Added initial support for integer casting operations to GRConstants.

llvm-svn: 46298
2008-01-24 02:02:54 +00:00
Ted Kremenek 4f1da522ca Minor tweak in GetValue to avoid an extra check for ParenExprs.
llvm-svn: 46294
2008-01-24 00:50:08 +00:00
Ted Kremenek 2517423c3c Implemented value tracking support for '*' and '*='.
Added "multiplication" support for equality sets.

llvm-svn: 46289
2008-01-23 23:42:27 +00:00
Ted Kremenek 5e02dc1b46 Implemented value tracking support for '+=' and '-='.
llvm-svn: 46288
2008-01-23 23:38:00 +00:00
Ted Kremenek cefae084a3 Removed extra GraphViz node attributes for GRConstants, as some of them were
causing problems with Dot.

llvm-svn: 46285
2008-01-23 22:54:57 +00:00
Ted Kremenek 930191c011 some prettying of the GraphViz visualization of GRConstants analysis results.
llvm-svn: 46284
2008-01-23 22:30:44 +00:00
Ted Kremenek 0a8d3767a3 Major "architectural" changes to the GRConstants analysis. We now reason about
abstract "L-values" and "R-values" when doing value tracking, and expanding
constant tracking to encompass tracking disjunctive sets of possible constants.
Further, the tree-walking is more efficient, as we don't blindly recurse the
tree if we won't generate new states.

llvm-svn: 46278
2008-01-23 19:59:44 +00:00
Ted Kremenek 111ede6c00 Fixed bug in 'GetBinding' when doing the lookup of stored values. We now
use ImmutableMap::SlimFind(), which returns the correct value.

Added pruning of dead block-level expressions and Decls from our value map
using liveness information.

llvm-svn: 46154
2008-01-18 00:41:32 +00:00
Ted Kremenek 05ecfddfc3 Fixed bug in 'LiveVariables' analysis where we incorrectly marked a variable
dead at an assignment without taking into account if the variable was used in
the RHS of the assignment.

llvm-svn: 46153
2008-01-18 00:40:21 +00:00
Ted Kremenek 85be7cf8ca Modified the notion of "Block-level expressions" in CFGs to include Stmt*. This
is because GNU-style Statement-expressions cause the last statement in the
statement-expression to act like an expression.

We now have two notions: block-level statements and block-level expressions.

The former are all Stmt* that appear in the list of statements in CFGBlocks. The
latter is the subset of the former; these block-level statements are used as
subexpressions somewhere in the AST. CFG::isBlockExpr() returns true for the
latter, not the former (previously isBlockExpr() always returned true for
non-Expr Stmt*).

Modified the LiveVariables analysis to also track liveness state for block-level
expressions (using the updated definition of block-level expressions).

Modified the dataflow solver so that when it records values for block-level
statements, it records the dataflow value *before* the transfer function for a
Stmt* is evaluated (not after). This is more in sync in what clients will want.

Modified CFGStmtVisitor to record the current block-level statement.

llvm-svn: 46143
2008-01-17 20:48:37 +00:00
Ted Kremenek b4b65e6319 Added support to dataflow solver to (when requested) also record dataflow
values for the block-level expressions.

Modified 'LiveVariables' to provide the option to clients to record
liveness information for block-level expressions (using the above feature).

Modified 'DeadStores' to conform to the new interface of 'LiveVariables'.

Modified 'GRConstants' to compute liveness information for block-level
expressions.

llvm-svn: 46137
2008-01-17 18:25:22 +00:00
Ted Kremenek f1dae23b68 Removed FindDeclRef, and used Expr::IgnoreParens instead (code refactoring).
llvm-svn: 46133
2008-01-17 17:50:49 +00:00
Ted Kremenek fff70962bb Added method Expr::IgnoreParens(), which returns the first non-ParenExpr Expr*.
Refactored the use of this method into both the Sema module and Analysis module,
which were using their own static functions that did the same thing.

llvm-svn: 46129
2008-01-17 16:57:34 +00:00
Ted Kremenek e780f408b1 Added some experimental optimizations to remove dead values from the
state.

llvm-svn: 46106
2008-01-17 00:52:48 +00:00
Ted Kremenek 506e507508 Changed sorting criteria for DSPtr to put sub-expressions first in the value
map. This will allow us to quickly prune them from maps without searching the
entire map.

llvm-svn: 46101
2008-01-16 23:35:31 +00:00
Ted Kremenek 692b01b0be Changed sorting criteria for DSPtr to sort Decl* before Expr*, and
to sort sub-expressions before Block-level expressions.

llvm-svn: 46100
2008-01-16 23:33:44 +00:00
Ted Kremenek a14396d51d IntegerLiterals are no longer evaluated to create separate nodes; their
values are determined when evaluating the parent expression.

llvm-svn: 46096
2008-01-16 22:28:08 +00:00
Ted Kremenek 493444fc19 Fixed bug where we performed addition instead of subtraction during
constant propagation.

llvm-svn: 46095
2008-01-16 22:20:36 +00:00
Ted Kremenek e914bb8183 Fixed iterator bug in ExplodedNodeImpl::NodeGroup::end(); we would improperly
handle the case where the number of nodes was 0.

Fixed bug in GREngineImpl where we did not proceed to the next statement
when processing a PostStmt location.

llvm-svn: 46093
2008-01-16 22:13:19 +00:00
Ted Kremenek ac886cb835 Added initial graph visualization support for the GRConstants analysis.
llvm-svn: 46092
2008-01-16 21:46:15 +00:00
Ted Kremenek 88d5909bed Added support from retrieving stored values to variables.
llvm-svn: 46087
2008-01-16 19:47:19 +00:00
Ted Kremenek 47b62c1a5f Added support for assignments in GRConstants.
llvm-svn: 46086
2008-01-16 19:42:59 +00:00
Ted Kremenek 7e7070b594 Fixed bug where GRConstants::AddBindings() did not check for values
that were "not a constant."

llvm-svn: 46085
2008-01-16 19:28:16 +00:00
Ted Kremenek deac51943a Fixed bug in cleanup of nodes in ExplodedNodeImpl where we should directly
call the dstor instead of using delete.

llvm-svn: 46084
2008-01-16 19:27:42 +00:00
Ted Kremenek 2e12c2e790 Hooked up the GRConstants analysis to the driver.
Fixed some compilation errors with GREngine that showed up during
template instantiation.

llvm-svn: 46074
2008-01-16 18:18:48 +00:00
Ted Kremenek 2d700ed2ba More cleanups in DoStmt. The NodeSets are now vectors instead of sets, since
node caching in GREngine will guarantee that we do not insert a node twice into
a nodeset.

llvm-svn: 46071
2008-01-16 17:56:25 +00:00
Ted Kremenek 73e5f2bb17 Adjusted DSPtr::Profile method again, since my last patch broke the build.
llvm-svn: 46051
2008-01-16 05:51:13 +00:00
Ted Kremenek 29185f17e9 Changed 'Profile' method for DSPtr to incorporate the flags from the
variant type, and not just the pointer value.

llvm-svn: 46049
2008-01-16 05:49:09 +00:00
Ted Kremenek fb55354fc9 Renamed some internal classes for the GR-Constant Propagation analysis.
Cleaned up GRConstants::AddBinding to not directly reference the
predecessor node.  Now we just manipulate the current state, and a driver
function creates nodes as needed.

llvm-svn: 46040
2008-01-16 00:53:15 +00:00
Ted Kremenek de8d62b132 Added skeleton implementation of new constant-prop. analysis using
the graph reachability engine.

llvm-svn: 46036
2008-01-15 23:55:06 +00:00
Ted Kremenek e584359716 Removed implicit transitions to a "BlockExit" location; we now handle
the end of the block by processing empty blocks (at BlockEntrance) or
when we have just processed the last statement in a block (at PostStmt).

llvm-svn: 45991
2008-01-15 00:24:08 +00:00
Ted Kremenek 3e743661c5 Added prototype implementation of path-sens. analysis core engine.
llvm-svn: 45986
2008-01-14 23:24:37 +00:00
Ted Kremenek d122bbdb06 Moved destructor logic of templated class ExplodedGraph to non-templated
parent class ExplodedGraphImpl.

llvm-svn: 45930
2008-01-13 05:33:04 +00:00
Ted Kremenek eb370bc386 Created ExplodedGraph.cpp and moved most method implementations of
ExplodedNodeImpl::NodeGroup from being defined inline to being defined
"out-of-line" in ExplodedGraph.cpp. This removes a dependence on including
<vector> in ExplodedGraph.h, and will hopefully result in smaller generated code
with negligible performance impact.

llvm-svn: 45928
2008-01-13 04:56:13 +00:00
Ted Kremenek 5906b9e79a Added ProgramPoint.cpp, which implements several methods of the subclasses
of ProgramPoint.

llvm-svn: 45866
2008-01-11 16:36:20 +00:00
Ted Kremenek e5ccf9a96c Renamed ProgramEdge to ProgramPoint and changed subclasses of ProgramEdge
to have a much simpler, cleaner interpretation of what is a "location"
in a function (as encoded by a CFG).

llvm-svn: 45846
2008-01-11 00:40:29 +00:00
Ted Kremenek fed4cce0cc Removed some files related to the path-sensitive solver as part of some
code restructuring.  (new files will be introduced shortly)

llvm-svn: 45785
2008-01-09 22:49:37 +00:00
Ted Kremenek 96b1ce4f0a Added VISIBILITY_HIDDEN to classes/structs in anonymous namespaces.
llvm-svn: 45750
2008-01-08 18:19:08 +00:00
Ted Kremenek 551e4ce74e Relocated comment in header.
llvm-svn: 45728
2008-01-08 00:07:06 +00:00
Ted Kremenek 35ff5b0ee6 Added more boilerplate for processing end-of-paths.
llvm-svn: 45724
2008-01-07 22:22:13 +00:00
Ted Kremenek 8569309bca Added ownership of "checker state" within the ExplodedGraph. Moved code that
creates the initial root node from the constructor of ReachabilityEngine to
ReachabilityEngine::ExecuteWorklist.

llvm-svn: 45722
2008-01-07 21:56:52 +00:00
Ted Kremenek 9dbf8a93a7 Renamed SimulVertex, SimulGraph, and SimulEngine to:
ExplodedNode, ExplodedGraph  (to match the vocabulary in the RHS paper)
  ReachabilityEngine
  
The implementation of the core of the path-sensitive dataflow solver has
been de-templatized and places in ReachabilityEngine.cpp.

The solver is still incomplete.

llvm-svn: 45711
2008-01-07 19:08:42 +00:00
Ted Kremenek 739d350369 renamed class "GRCP" (Graph Reachabilty Constant Propagation) to
"GREngine" (Graph Reachability Engine).  The idea is to provide a separation
of concerns between the constant prop. details and the core analysis engine.

llvm-svn: 45555
2008-01-03 22:46:25 +00:00
Ted Kremenek 7c54e520e7 Implemented End-Of-Path processing.
llvm-svn: 45554
2008-01-03 22:29:38 +00:00
Ted Kremenek 0044908de0 Initial checking of GRConstantPropagation.cpp, which implements a constant
propagation analysis via graph reachability. This analysis (which is incomplete)
will be the basis for later developments on the core engine for path-sensitive
analysis analysis.

llvm-svn: 45552
2008-01-03 22:12:28 +00:00
Chris Lattner 5926c0ebfb remove attribution from makefiles.
llvm-svn: 45412
2007-12-29 20:02:25 +00:00
Chris Lattner 5b12ab8c93 Don't attribute in file headers anymore. See llvmdev for the
discussion of this change.

llvm-svn: 45410
2007-12-29 19:59:25 +00:00
Ted Kremenek bf593f81fa Directory restructing of Analysis files.
Created include/clang/Analysis/Analyses directory.
  - Moved LiveVariables.h and UninitializedValues.h into this dir.
  
Moved ExprDeclBitVector.h into Analysis/Support.

Updated all clients who use these headers to reflect the new paths.

llvm-svn: 45292
2007-12-21 21:42:19 +00:00
Ted Kremenek 3a742d280c For uninitialized values analysis, added special treatment for declarations
of array types.  For things like:

  char x[10];
  
we should treat "x" as being initialized, because the variable "x" really
refers to the memory block of the array. Clearly x[1] is uninitialized, but
expressions like "(char*) x" really do refer to an initialized value. This
simple dataflow analysis does not reason about the contents of arrays.

This fixes: PR 1859 (http://llvm.org/bugs/show_bug.cgi?id=1859)

llvm-svn: 44984
2007-12-13 05:14:22 +00:00
Ted Kremenek 78dcda6059 Fixed bug in live-variable analysis and uninitialized-values analysis where
we incorrectly examine the expression within a sizeof() for use in computing
dataflow values.

This fixes: PR 1858 (http://llvm.org/bugs/show_bug.cgi?id=1858)

llvm-svn: 44982
2007-12-13 04:47:15 +00:00
Ted Kremenek 1daa3cfbae TargetInfo no longer includes a reference to SourceManager.
Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation.
Added many utility methods to FullSourceLoc to provide shorthand for:

    FullLoc.getManager().someMethod(FullLoc.getLocation());
    
instead we have:

    FullLoc.someMethod();
    
Modified TextDiagnostics (and related classes) to use this short-hand.

llvm-svn: 44957
2007-12-12 22:39:36 +00:00
Ted Kremenek d4e5fbacab Mega-patch: ripped SourceManager out of Diagnostic/DiagnosticClient. Now
SourceManager is passed by reference, allowing the SourceManager to be
associated with a specific translation unit, and not the entire execution
of the driver.

Modified all users of Diagnostics to comply with this new interface.

Integrated SourceManager as a member variable of TargetInfo. TargetInfo will
eventually be associated with a single translation unit (just like
SourceManager).

Made the SourceManager reference in ASTContext private. Provided accessor
getSourceManager() for clients to use instead. Modified clients to comply with
new interface.

llvm-svn: 44878
2007-12-11 21:27:55 +00:00
Anders Carlsson 801c5c7467 GCC has an extension where the left hand side of the ? : operator can be omitted. Handle this in a few more places.
llvm-svn: 44462
2007-11-30 19:04:31 +00:00
Ted Kremenek 2e04d73d83 Fixed bogus culling of uninitialized-values "taint" propagation during assignments.
We accidentally were throttling the propagation of uninitialized state across
assignments (e.g. x = y).  Thanks to Anders Carlsson for spotting this problem.

Added test cases to test suite to provide regression testing for the
uninitialized values analysis.

llvm-svn: 44306
2007-11-24 20:07:36 +00:00
Ted Kremenek 9d0acca967 Updated CFGStmtVisitor and CFGRecStmtVisitor to have a notion of
"block-expressions" when visiting arbitrary expressions (via calls to
"Visit()").  This results in a refactoring where a dataflow analysis no
longer needs to always special case when handling block-expressions versus
non-block expressions.

Updated LiveVariables and UninitializedValues to conform to the slightly
altered interface of these visitor classes.

Thanks to Nuno Lopes for providing a test case that illustrated some
fundamental problems in the current design of the CFGXXXStmtVisitor classes
and how they were used.

llvm-svn: 44246
2007-11-20 03:01:58 +00:00
Ted Kremenek 850f1155ad Fixed bug where LiveVariables was not properly propagating updates to liveness
state that occurred in subexpressions of Block-Level expressions. Bug and fix
provided by Nuno Lopes.

llvm-svn: 44224
2007-11-19 06:36:49 +00:00
Chris Lattner a7c19feca2 Add a new Rewriter::getRangeSize method.
Rename SourceRange::Begin()/End() to getBegin()/getEnd() for
consistency with other code.
Start building the rewriter towards handling @encode.

llvm-svn: 43047
2007-10-16 22:36:42 +00:00
Chris Lattner ef6b136781 move IdentifierTable.h from liblex to libbasic.
llvm-svn: 42730
2007-10-07 08:58:51 +00:00
Ted Kremenek fb4750b639 Migrated LiveVariables and UninitializedVariables to now use the
tracked BlkExpr information now maintained by the CFG class.

llvm-svn: 42498
2007-10-01 20:33:52 +00:00
Ted Kremenek 14851c3de3 Fixed bug where assignments to variables wrapped in parentheses would not
properly kill variables.  e.g:

(x) = 1;

llvm-svn: 42450
2007-09-28 21:29:33 +00:00
Ted Kremenek a1c256dd0e Fixed UninitializedValues to properly propagate uninitialized "taint"
in assignment operations of the form +=, -=, *=, etc.

llvm-svn: 42449
2007-09-28 21:08:51 +00:00
Ted Kremenek a6ef56e6d2 DeadStores no longer reports warnings for stores to non-local variables.
llvm-svn: 42447
2007-09-28 20:48:41 +00:00
Ted Kremenek 0064ff47e6 Significant cleanups and bug-fixes to LiveVariables. Uses new refactored
ExprDeclBitVector class for defining dataflow state.

llvm-svn: 42446
2007-09-28 20:38:59 +00:00
Ted Kremenek f91d1c92ba Fixed several bugs in the propagation of "uninitialized value"
taintness across expressions.

Made "smart-culling" of taint propagation (for error reporting)
correctly handle conditional expressions and a few other edge cases.

llvm-svn: 42421
2007-09-28 00:09:38 +00:00
Ted Kremenek b9ce295b0a Created new "ExprDeclBitVector" type bundle for dataflow analyses that need boolean
values associated with ScopedDecls and CFGBlock-level Exprs.  This is the common
boilerplate needed by UninitializedValues and LiveVariables.

Refactored UninitializedValues to use ExprDeclBitVector.

Shortened the string diagnostic for UninitializedValues.

llvm-svn: 42408
2007-09-27 18:20:22 +00:00
Ted Kremenek 39fc60f280 Moved "DataflowSolver.h" to the "include/" subtree. Adjusted client
code that uses the solver to reflect the new location.

Created "FlowSensitive" subdirectory in include/clang/Analysis to hold
header files relating to flow-sensitive analyses.  Moved
"DataflowValues.h" into this subdirectory.

llvm-svn: 42320
2007-09-25 21:00:24 +00:00
Ted Kremenek 2af52eb454 Comment formatting changes. No real content changes.
llvm-svn: 42305
2007-09-25 17:53:38 +00:00
Ted Kremenek 67f6ea19d7 Minor comment changes.
llvm-svn: 42304
2007-09-25 17:51:05 +00:00
Ted Kremenek 9716d61923 Removed "EverKilled" class in DeadStores checker; it is no longer used.
llvm-svn: 42301
2007-09-25 17:47:04 +00:00
Ted Kremenek ad8bce02f0 Further refactored DataflowSolver. Now most code for the solver is shared
between forward and backward analyses, with trait classes being used
to implement the key differences in operations/functionality.

Converted the LiveVariables analysis to use the generic DataflowSolver.  This,
along with removing some extra functionality that was not needed, reduced
the code for LiveVariables by over half.

Modified Driver code to handle the updated interface to LiveVariables.

Modified the DeadStores checker to handle the update interface to
LiveVariables.

Updated DataflowValues (generic ADT to store dataflow values) to also
store values for blocks.  This is used by DeadStores.  Updated some comments.

llvm-svn: 42293
2007-09-25 04:31:27 +00:00
Ted Kremenek 24c624477e Updated header file inlcude to new location of
Analysis/Visitors/*Visitors.h files.

llvm-svn: 42175
2007-09-20 21:42:55 +00:00
Hartmut Kaiser 8a43d50f40 Updated VC++ project files.
Disambiguated a variable.

llvm-svn: 42161
2007-09-20 13:35:09 +00:00
Ted Kremenek ec55ce39a6 More refactoring: decl and expr regisitration now uses CFGRecStmtDeclVisitor.
llvm-svn: 42145
2007-09-19 18:00:03 +00:00
Ted Kremenek fb9ea52a13 DataflowSolver now acccepts an "_Equal" template parameter that allows the user
to specify how two dataflow values should be compared for equality.  The default
is to use std::equal_to.

llvm-svn: 42115
2007-09-18 23:40:51 +00:00
Ted Kremenek 9427b0e23b Changed solver to use "==" operator when comparing dataflow values
rather than a special "equal" method defined in the class for the
value.

llvm-svn: 42113
2007-09-18 23:30:21 +00:00
Ted Kremenek 8d4dcc5409 Minor performance fix in transfer function logic. Previously we
called VisitStmt, but VisitChildren is more direct and creates less
boilerplate logic.

llvm-svn: 42110
2007-09-18 21:47:41 +00:00
Ted Kremenek 271161078b More refactoring and code reduction.
llvm-svn: 42109
2007-09-18 21:43:18 +00:00
Ted Kremenek b1361eaaa7 Add overloaded versions of DataflowSolver::runOnBlock to simplify
invocation of the solver.

UninitializedValues checker now uses CFG::runOnAllBlocks to query the
computed dataflow values (tighter code).

llvm-svn: 42107
2007-09-18 21:08:21 +00:00
Ted Kremenek 360c3b4abb Added member template CFG::VisitBlockStmts to provide a succinct way
of visiting all block-level statements in a CFG.

Tightened implementation of UninitializedValues.

llvm-svn: 42106
2007-09-18 20:59:00 +00:00
Ted Kremenek df9a2a9f8b Moved TransferFunction object within DataflowSolver to be a instance
variable instead of a temporary.

llvm-svn: 42102
2007-09-18 18:17:19 +00:00
Ted Kremenek 584e21a349 Modified DataFlowValues and DataflowSolver to associate dataflow value
with CFG *edges* instead of blocks.  This will fascilitate dataflow
analyses that are sensitive to block terminators, and also simplifies
some reasoning.

Updated UninitializedValues to comply to this new interface.

llvm-svn: 42099
2007-09-18 18:02:44 +00:00
Ted Kremenek 3c996d9a60 Bug fix to merging of data flow values (merge incorrectly made values
too "conservative").

Several revisions to UninitializedValues checker after testing.  We
now appear to be working correctly (probably some bugs still, but main
functionality appears to be there).  Implemented careful emitting of
warnings so that we wouldn't get a cascade of warnings for simply not
defining a single variable and using it everywhere.  This way the
warnings point closer to the root cause rather than "symptoms" from
using values derived from uninitialized variables.

llvm-svn: 42067
2007-09-17 21:59:08 +00:00
Ted Kremenek d0b206fd98 Renamed file due to mispelling.
llvm-svn: 42056
2007-09-17 20:50:02 +00:00
Ted Kremenek 7e61e81bbf UninitialuzedValues now only tracks BlockVarDecls; obviating false positives with
globals and function parameters.

llvm-svn: 42055
2007-09-17 20:49:30 +00:00
Ted Kremenek dd3015375c More progress on UnitializedValues checker. We now have preliminary support
for reporting errors and running the checker.

llvm-svn: 42046
2007-09-17 19:59:27 +00:00
Ted Kremenek 6f0751475a Split tracking of unitialized values for Decls and CFGBlock-level expressions.
llvm-svn: 42041
2007-09-17 18:31:23 +00:00
Ted Kremenek 789ea076a8 Removed "ObserverTy" from core DataflowValues types. The observer
mechanism can be implemented simply by affixing the Observer to an
analysis meta data, so it doesn't need to be a required type.  This
also permits analyses not to implement an Observer if it doesn't make
sense.

Changed "DataflowValues::MetaDataTy" to
"DataflowValues::AnalysisDataTy" to reflect that the type
enscapsulated the data associated with analyzing a given CFG.

Changed CFGStmtVisitor::BlockStmt_VisitImplicitControlFlowStmt(Stmt*)
to ...VisitImplicitControlFlowExpr(Expr*).  The type narrowing is more
precise and more useful to clients.

Added CFGStmtVisitor::BlockStmt_VisitExpr to reflect the visitation of
expressions at the block statement level.  This captures all implicit
control-flow statements as well as other expressions that are hoisted
to the block level (such as conditions for terminators and function
calls).  This is especially useful for dataflow analysis.

llvm-svn: 42034
2007-09-17 17:14:52 +00:00
Chris Lattner 254987c411 switch the various CFG-based stuff over to using ASTConsumer interface,
this eliminates their dependence on the preprocessor and eliminates some
duplicated code.

llvm-svn: 41993
2007-09-15 23:21:08 +00:00
Chris Lattner 1cf7bb15ea fix comment
llvm-svn: 41988
2007-09-15 21:48:50 +00:00