Ted Kremenek [Sat, 15 Nov 2008 04:01:56 +0000 (04:01 +0000)]
Reverted part of r59335: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20081110/009243.html
In that patch I added a bogus type promotion for unary '!'.
The real bug was more fallout from edges cases with compound assignments and conjured symbolic values. Now the conjured value has the type of the LHS expression, and we do a promotion to the computation type. We also now correctly do a conversion from the computation type back to the LHS type.
Ted Kremenek [Sat, 15 Nov 2008 00:20:05 +0000 (00:20 +0000)]
Implement FIXME in GRExprEngine::VisitUnaryOperator() to handle implicit conversions caused by the '!' operator. This required adding some logic to GRSimpleVals to reason about nonloc::LocAsInteger SVals. This code appears to work fine, but it should eventually be cleaned up.
Ted Kremenek [Fri, 14 Nov 2008 21:07:14 +0000 (21:07 +0000)]
Minor tweaks to liveness analysis:
- Block-expression for 'ObjCForCollectionStmt' is not alive before it occurs
- Recursively visit 'element' expression for ObjCForCollectionStmt to get liveness for referenced block-level expressions and variables.
Douglas Gregor [Fri, 14 Nov 2008 16:09:21 +0000 (16:09 +0000)]
Add a new expression node, CXXOperatorCallExpr, which expresses a
function call created in response to the use of operator syntax that
resolves to an overloaded operator in C++, e.g., "str1 +
str2" that resolves to std::operator+(str1, str2)". We now build a
CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But
only for binary operators, where we actually implement overloading)
I decided *not* to refactor the current CallExpr to make it abstract
(with FunctionCallExpr and CXXOperatorCallExpr as derived
classes). Doing so would allow us to make CXXOperatorCallExpr a little
bit smaller, at the cost of making the argument and callee accessors
virtual. We won't know if this is going to be a win until we can parse
lots of C++ code to determine how much memory we'll save by making
this change vs. the performance penalty due to the extra virtual
calls.
Douglas Gregor [Fri, 14 Nov 2008 12:46:07 +0000 (12:46 +0000)]
Don't require us to manually number the statements and expressions in StmtNodes.def. We don't need stable numbers yet, renumbering is a pain, and LAST_STMT had the wrong value anyway.
Steve Naroff [Thu, 13 Nov 2008 20:07:04 +0000 (20:07 +0000)]
Fix an obscure rewriter bug when rewriting implementations that don't have a corresponding interface (found while doing random testing on another bug).
Chris Lattner [Thu, 13 Nov 2008 18:52:53 +0000 (18:52 +0000)]
Fix a couple of suboptimalities in error recovery.
1. In the top level of ParseStatementOrDeclaration, don't eat a } if we
just parsed a statement if it list there. Also, don't even bother
emitting an error about a missing semicolon if the statement had a
bug (an rbrace is fine).
2. In do/while parsing, don't require a 'while' to be present if the do
body didn't parse.
This allows us to generate a clean diagnostic for this code:
t.c:1:22: error: expected expression
void foo (void) { do . while (0); }
^
Ted Kremenek [Thu, 13 Nov 2008 17:11:24 +0000 (17:11 +0000)]
Using llvm::OwningPtr<> for CurLexer and CurTokenLexer. This makes both the ownership semantics of these objects explicit within the Preprocessor and also tightens up the code (explicit deletes not needed).
Ted Kremenek [Thu, 13 Nov 2008 16:51:03 +0000 (16:51 +0000)]
Use PushIncludeMacroStack/PopMacroStack instead of manually pushing/popping from IncludeMacroStack. This is both cleaner and makes the include stack transparently extensible.
Zhongxing Xu [Thu, 13 Nov 2008 07:58:20 +0000 (07:58 +0000)]
Lift the pointer to alloca'ed region to the pointer to its first element.
This is required by some operations, e.g., *p = 1; p[0] = 1;.
Also set the AllocaRegion's type during the cast.
Ted Kremenek [Thu, 13 Nov 2008 06:10:40 +0000 (06:10 +0000)]
GRExprEngine/CFRefCount/GRSimpleVals: We don't do any special handling (yet) of vector types. Add explicit checks that when we process integers that they really are scalars.
Eli Friedman [Thu, 13 Nov 2008 06:09:17 +0000 (06:09 +0000)]
Fix for crash issues with comma operators with a void first operand, and
some more bullet-proofing/enhancements for tryEvaluate. This shouldn't
cause any behavior changes except for handling cases where we were
crashing before and being able to evaluate a few more cases in tryEvaluate.
This should settle the minor mess surrounding r59196.
Daniel Dunbar [Thu, 13 Nov 2008 05:29:02 +0000 (05:29 +0000)]
Obey the FIXMES!
- Resume running the always inliner pass always now that LLVM has
been improved and functions with debug info can be inlined.
- Remove unused header.
Daniel Dunbar [Thu, 13 Nov 2008 05:09:21 +0000 (05:09 +0000)]
[LLVM up] Update for raw_fd_ostream change. This fixes a FIXME that
the Backend output should be done in binary mode.
- I'd appreciate it if someone who has a Windows build could verify
this.
Eli Friedman [Thu, 13 Nov 2008 02:13:11 +0000 (02:13 +0000)]
Backout of r59196, plus a new ICE test. Sorry if this is a
little rude; I figure it's cleaner to just back this out now so
it doesn't get forgotten or mixed up with other checkins.
The modification to isICE is simply wrong; I've added a test that the
change to isICE breaks.
I'm pretty sure the modification to tryEvaluate is also wrong.
At the very least, there's some serious miscommunication going on here,
as this is going in exactly the opposite direction of r59105. My
understanding is that tryEvaluate is not supposed to care about side
effects. That said, a lot of the clients to tryEvaluate are
expecting it to enforce a no-side-effects policy, so we probably need
another method that provides that guarantee.
Daniel Dunbar [Thu, 13 Nov 2008 01:54:24 +0000 (01:54 +0000)]
Supply finished flag to EmitBlock for common statements which use
landing pads.
- Primarily a cleanliness issue instead of a performance issue (this
eliminates all blocks w/o predecessors on 176.gcc/expr.c), but this
also allows subsequent code to recognize it is unreachable and
potentially avoid IRgen.
Daniel Dunbar [Thu, 13 Nov 2008 01:24:05 +0000 (01:24 +0000)]
Add IsFinished arg to EmitBlock.
- Indicates that caller is done with the block and it can be dropped
if it has no predecessors. Useful for callers who need to make
landing pads but which may not be reached.
Daniel Dunbar [Thu, 13 Nov 2008 00:03:19 +0000 (00:03 +0000)]
Fix bug in constant evaluation exposed by 176.gcc.
- Evaluation of , operator used bogus assumption that LHS could be
evaluated as an integral expression even though its type is
unspecified.
This change is making isICE very permissive of the LHS in non-evaluated
contexts because it is not clear what predicate we would use to reject
code here. The standard didn't offer me any guidance; opinions?
Douglas Gregor [Wed, 12 Nov 2008 23:21:09 +0000 (23:21 +0000)]
Don't build identifiers for C++ constructors, destructors, or
conversion functions. Instead, we just use a placeholder identifier
for these (e.g., "<constructor>") and override NamedDecl::getName() to
provide a human-readable name.
This is one potential solution to the problem; another solution would
be to replace the use of IdentifierInfo* in NamedDecl with a different
class that deals with identifiers better. I'm also prototyping that to
see how it compares, but this commit is better than what we had
previously.
Ted Kremenek [Wed, 12 Nov 2008 22:43:05 +0000 (22:43 +0000)]
Move LexIncludeFilename from Lexer to PreprocessorLexer.
PreprocessorLexer now has a virtual method "IndirectLex" which allows it to call the lex method of its subclasses. This is not for performance intensive operations.
Ted Kremenek [Wed, 12 Nov 2008 22:10:22 +0000 (22:10 +0000)]
Add Preprocessor::PushIncludeMacroStack() and Preprocessor::PopIncludeMacroStack(), two utility methods for manipulating the Preprocessor stack. These will be used to remove manually manipulation of IncludeMacroStack from the rest of the Preprocessor implementation.
Ted Kremenek [Wed, 12 Nov 2008 21:33:59 +0000 (21:33 +0000)]
Move pieces of Lexer that the Preprocessor mutates to a new base class 'PreprocessorLexer'. This will also be the base class of the new Preprocessed-Token-Header (PTH) lexer. No functionality change.
GRState:
- Environment now binds to Stmt* instead of Expr*. This is needed for processing ObjCForCollectionStmt (essentially the declaration of the the 'element' variable can have an SVal attached to it).
- BindDecl no longer accepts Expr* for the initialization value; use SVal* instead.