Ted Kremenek [Mon, 28 Jan 2008 22:09:13 +0000 (22:09 +0000)]
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".
Steve Naroff [Mon, 28 Jan 2008 02:00:41 +0000 (02:00 +0000)]
Fix a bug with struct initializers (in Sema::CheckInitializerListTypes()).
Test case included from bz1948 (thanks Neil!).
Also fixed an 80 column violation...
Ted Kremenek [Sat, 26 Jan 2008 00:03:27 +0000 (00:03 +0000)]
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).
Ted Kremenek [Fri, 25 Jan 2008 18:28:28 +0000 (18:28 +0000)]
When adding assignment expressions to the set of block-level expressions, only
include the assignment expressions whose result (as in the value of the
expression) is used by other expressions.
Steve Naroff [Fri, 25 Jan 2008 00:51:06 +0000 (00:51 +0000)]
Replace Sema::CheckVariableInitList, CheckConstantInitList, and CheckForCharArrayInitializer with CheckInitializerListTypes. The new routine now supports struct/union initializers.
This is a modified version of a patch by Eli Friedman. This version passes all of the clang tests and supports vectors:-)
Note that Eli and I are still unsatisfied the implementation of CheckInitializerListTypes(). We'd like to find a more elegant implementation. Nevertheless, this is a complex part of the standard (and may be hard to simplify). Since the complexity is localized to this routine, we can iterate without too much disruption:-)
Ted Kremenek [Thu, 24 Jan 2008 23:19:54 +0000 (23:19 +0000)]
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.
Ted Kremenek [Thu, 24 Jan 2008 19:43:37 +0000 (19:43 +0000)]
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.
Ted Kremenek [Thu, 24 Jan 2008 19:00:57 +0000 (19:00 +0000)]
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).
Ted Kremenek [Thu, 24 Jan 2008 08:20:02 +0000 (08:20 +0000)]
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).
Fixed a nasty bug which took a while to come up with a test case,
diagnose, and took even longer to fix. It has to do with rewriting of a message
receiver which is an 'ivar' reference. Fix, however, is to remove a code which
was not doing the right thing and no longer needed.
Ted Kremenek [Wed, 23 Jan 2008 19:59:44 +0000 (19:59 +0000)]
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.
Steve Naroff [Sat, 19 Jan 2008 00:42:38 +0000 (00:42 +0000)]
Fix two bugs with an @throw that doesn't have a statement.
- ObjCAtThrowStmt::getSourceRange() needs to check if it has a statement (and not go "boom":-)
- RewriteTest::RewriteObjCThrowStmt() needs to generate refer to the current exception.
Ted Kremenek [Fri, 18 Jan 2008 00:40:21 +0000 (00:40 +0000)]
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.
Steve Naroff [Fri, 18 Jan 2008 00:39:39 +0000 (00:39 +0000)]
Sema::FinalizeDeclaratorGroup()...make sure we emit an diagnostic for tentative definitions with incomplete types. Touch up all test cases that are effected.
Ted Kremenek [Fri, 18 Jan 2008 00:38:55 +0000 (00:38 +0000)]
Changed DataflowSolver to always associated recorded dataflow values with
the position *before* a statement, regardless of whether we are doing a
forward or backwards analysis.
Ted Kremenek [Thu, 17 Jan 2008 20:48:37 +0000 (20:48 +0000)]
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.
Nate Begeman [Thu, 17 Jan 2008 17:46:27 +0000 (17:46 +0000)]
Implement basic overload support via a new builtin, __builtin_overload.
__builtin_overload takes 2 or more arguments:
0) a non-zero constant-expr for the number of arguments the overloaded
functions will take
1) the arguments to pass to the matching overloaded function
2) a list of functions to match.
The return type of __builtin_overload is inferred from the function whose args
match the types of the arguments passed to the builtin. For example:
float a;
float sinf(float);
int sini(int);
float b = __builtin_overload(1, a, sini, sinf);
Says that we are overloading functions that take one argument, and trying to
pass an argument of the same type as 'a'. sini() does not match since it takes
and argument of type int. sinf does match, so at codegen time this will turn
into float b = sinf(a);
Ted Kremenek [Thu, 17 Jan 2008 16:57:34 +0000 (16:57 +0000)]
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.