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.
Ted Kremenek [Wed, 16 Jan 2008 23:35:31 +0000 (23:35 +0000)]
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.
Chris Lattner [Wed, 16 Jan 2008 19:17:22 +0000 (19:17 +0000)]
Move promoteExprToType from being a static method in SemaExpr.cpp to being
a method named ImpCastExprToType in Sema.
Use this method to insert implicit casts for case statements from their
operand type to the condition type of the switch. This fixes a crash on
test/CodeGen/statements.c, reported by Eli Friedman.
Ted Kremenek [Wed, 16 Jan 2008 17:56:25 +0000 (17:56 +0000)]
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.
Ted Kremenek [Wed, 16 Jan 2008 00:53:15 +0000 (00:53 +0000)]
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.
Steve Naroff [Tue, 15 Jan 2008 22:21:49 +0000 (22:21 +0000)]
Finish up handling all permutations of "complex int" (in Sema::UsualArithmeticConversions()).
A FIXME remains to verify the conversion rules are consistent with GCC.
Steve Naroff [Tue, 15 Jan 2008 19:36:10 +0000 (19:36 +0000)]
- Change Type::isComplexType() to exlude GCC's complex integer extension. In general, we will keep the lowest level Type predicates "pure" (i.e. true to the C99 spec).
- Modify Sema::UsualArithmeticConversions() to work with the new definition of Type::isComplexType().
This is a nice cleanup and also fixes a bug submitted by Eli (which I've added to the test suite).
Steve Naroff [Tue, 15 Jan 2008 01:41:59 +0000 (01:41 +0000)]
Rework commit r45976, which was incorrect.
- Add Type::isComplexIntegerType(), Type::getAsComplexIntegerType().
- Don't inlude complex types with Type::isIntegerType(), which is too general.
- Use the new predicates in Sema::UsualArithmeticConversions() to recognize/convert the types.
Ted Kremenek [Tue, 15 Jan 2008 00:24:08 +0000 (00:24 +0000)]
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).
Ted Kremenek [Mon, 14 Jan 2008 18:29:39 +0000 (18:29 +0000)]
When serializing CompoundLiteralExpr, serialize out the file scope flag before
serializing the subexpression (Init), as this results in a more efficient
encoding in the bitstream.
Steve Naroff [Mon, 14 Jan 2008 18:19:28 +0000 (18:19 +0000)]
Record if a compound literal expression is @ file scope. This allows us to implement C99 6.5.2.5p6. This could have been done without modifying the AST (by checking the decl type and passing the info down to isContextExpr), however we concluded this is more desirable.
Chris Lattner [Mon, 14 Jan 2008 05:45:46 +0000 (05:45 +0000)]
Fix ASTContext::typesAreCompatible when analyzing a function type with
proto and function type without proto. It would never call
'functionTypesAreCompatible' because they have different type classes.
Steve Naroff [Sun, 13 Jan 2008 17:10:08 +0000 (17:10 +0000)]
Change Sema::CheckAddressOfOperation() to respect C99-only addressof rules.
Remove diagnostics from Sema::CheckIndirectionOperand(). C89/C99 allow dereferencing an incomplete type. clang appears to be emulating some incorrect gcc behavior (see below).
void
foo (void)
{
struct b;
struct b* x = 0;
struct b* y = &*x; // gcc produces an error ("dereferencing pointer to incomplete type")
}
Ted Kremenek [Sun, 13 Jan 2008 04:56:13 +0000 (04:56 +0000)]
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.
Ted Kremenek [Sun, 13 Jan 2008 03:55:50 +0000 (03:55 +0000)]
Changed implementation of successor and predecessor sets for ExplodedNode
to optimize for the common case of having a single predecessor and a single
successor.
Chris Lattner [Sat, 12 Jan 2008 06:43:35 +0000 (06:43 +0000)]
When forming the squigly underline for a diagnostic, make sure to
verify that the source range corresponds to the current file, not
just the current line. This allows us to emit:
a.c:1:44: error: invalid operands to binary expression ('double' and 'int *')
double a; int *b; void f(void) { int c = a +
~ ^
instead of:
a.c:1:44: error: invalid operands to binary expression ('double' and 'int *')
double a; int *b; void f(void) { int c = a +
~ ~ ^
Ted Kremenek [Fri, 11 Jan 2008 00:40:29 +0000 (00:40 +0000)]
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).