Commit Graph

49 Commits

Author SHA1 Message Date
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