Commit Graph

274 Commits

Author SHA1 Message Date
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
Ted Kremenek 5746d06a5d Prototype implementation of new template-based dataflow solver.
Preliminary implementation of UninitializedValues, which is based on
new solver (doesn't work yet, but compiles).

llvm-svn: 41970
2007-09-14 22:49:21 +00:00
Steve Naroff a23cc79654 Move Decl::NextDeclarator (w/ setters/getters) down to ScopedDecl/FieldDecl.
Decl is now svelte:-)

llvm-svn: 41935
2007-09-13 23:52:58 +00:00
Chris Lattner 5a5b35c07b make the sourcemgr available through ASTContext.
llvm-svn: 41906
2007-09-13 01:14:03 +00:00
Ted Kremenek 302def221c Minor space tightening.
Removed extraneous call to Observer->ObserveStmt when handling DeclRefExprs.

llvm-svn: 41890
2007-09-12 20:28:48 +00:00
Ted Kremenek fe1da5ec56 Fixed recursion bug: should call Visit on child instead of VisitStmt.
llvm-svn: 41888
2007-09-12 20:11:39 +00:00
Ted Kremenek 1147e36fe0 Migrated LiveVariables to use the new DataflowStmtVisitor interface. The code
is much simpler now.

llvm-svn: 41885
2007-09-12 19:10:52 +00:00
Ted Kremenek 2f1a79d329 For looking at "dead stores" in declarations, we now check to see
if the assigned value is a constant expression, e.g.:

int x = 0;

We then check to see if "x" is ever reassigned later.  If so, we don't
emit a warning.  This is because programmers frequently use defensive
programming to make sure a variable has a defined value.

llvm-svn: 41853
2007-09-11 17:24:14 +00:00
Ted Kremenek ca6c2b750b Fixed potential NULL dereference when iterating over a chain of Decls.
llvm-svn: 41848
2007-09-11 17:00:40 +00:00
Gabor Greif 412af03cee get rid of ugly "warning: no newline at end of file"
warnings that some compilers diagnose

llvm-svn: 41847
2007-09-11 15:32:40 +00:00
Ted Kremenek bd9cc5ca89 Fixed LiveVariables to no longer track the liveness of function pointers
that refer to direct function calls.

Modified interface of LiveVariables to only track liveness of VarDecls.
This cleans up a bunch of edge cases, and removed the bug just mentioned.

llvm-svn: 41797
2007-09-10 17:36:42 +00:00
Ted Kremenek cfe207c112 Renaming of the LiveVariablesAuditor interface. Changed "Auditor" and
"Audit" to "Observer" and "Observe"

llvm-svn: 41794
2007-09-10 15:56:38 +00:00
Ted Kremenek 3ce57c6baf Added more checking in "dead stores" for values that are initialized
but never used.

Fix a bug in LiveVariables where uses on the LHS of self-assign
operators (e.g +=, *=, etc) would not be properly recorded in the
liveness state of the variable.

llvm-svn: 41757
2007-09-06 23:39:53 +00:00
Ted Kremenek 10e7870746 Minor bug fixes to corner cases where LiveVariables would crash on some CFGs
that contained no declarations, or when a variable is declared but never used.

llvm-svn: 41756
2007-09-06 23:25:10 +00:00
Ted Kremenek 1bb9f2596f Forgot to check in the actual "dead stores" checker in the last commit!
llvm-svn: 41755
2007-09-06 23:01:46 +00:00
Ted Kremenek 6dc7b11d32 Added "Dead Stores", a flow-sensitive checker that checks for stores
to variables that are no longer live.  This analysis is built on top
of CFGs and the LiveVariables analysis.

changes to driver:
 added driver option "-check-dead-stores" to run the analysis

llvm-svn: 41754
2007-09-06 23:00:42 +00:00
Ted Kremenek 3f8ed2653c LiveVariables:
- Finished 99% of analysis logic.  Probably a few bugs.
 - Added querying functions to query liveness.
 - Added better pretty printing of liveness.
 - Added better bookkeeping of per-variable liveness information.
 - Added LiveVariablesAuditor interface, which allows "lazy" querying
   of intra-basic block liveness information.

Driver:
 - Minor cleanups involved in dumping liveness information.

llvm-svn: 41753
2007-09-06 21:26:58 +00:00
Ted Kremenek b56a990955 Added an early implementation of Live-Variables analysis built on
source-level CFGs.  This code may change significantly in the near
future as we explore different means to implement dataflow analyses.

Added a driver option, -dump-live-variables, to view the output of
live variable analysis.  This output is very ALPHA; it will be improved shortly.

llvm-svn: 41737
2007-09-06 00:17:54 +00:00