Chris Lattner [Sat, 21 Jul 2007 03:09:58 +0000 (03:09 +0000)]
Fix off-by-one error when emitting diagnostics. Also, make diagnostic
a bit nicer for people who pass lots of extra arguments to calls by
selecting them all instead of just the first one:
arg-duplicate.c:13:13: error: too many arguments to function
f3 (1, 1, 2, 3, 4); // expected-error {{too many arguments to function}}
^~~~~~~
This implements test/Sema/arg-duplicate.c, thanks to Neil for pointing
out this crash.
Chris Lattner [Sat, 21 Jul 2007 03:00:26 +0000 (03:00 +0000)]
Two fixes:
1) fix a crash on test/Sema/default.c by making
sure that the switch scope is non-null.
2) if there is an error sema'ing a default or case stmt,
make sure to return the substmt up, so that the error
recovery code has more acurate info to continue with.
Chris Lattner [Fri, 20 Jul 2007 18:00:12 +0000 (18:00 +0000)]
improve comments, implement a trivial single-entry cache in
SourceManager::getInstantiationLoc. With this change, every token
expanded from a macro doesn't get its own MacroID. :)
This reduces # macro IDs in carbon.h from 16805 to 9197
Chris Lattner [Fri, 20 Jul 2007 16:59:19 +0000 (16:59 +0000)]
At one point there were going to be lexer and parser tokens.
Since that point is now long gone, we should rename LexerToken to
Token, as it is the only kind of token we have.
Chris Lattner [Fri, 20 Jul 2007 16:37:10 +0000 (16:37 +0000)]
Reimplement SourceLocation. Instead of having a
fileid/offset pair, it now contains a bit discriminating between
mapped locations and file locations. This separates the tables for
macros and files in SourceManager, and allows better separation of
concepts in the rest of the compiler. This allows us to have *many*
macro instantiations before running out of 'addressing space'.
This is also more efficient, because testing whether something is a
macro expansion is now a bit test instead of a table lookup (which
also used to require having a srcmgr around, now it doesn't).
This is fully functional, but there are several refinements and
optimizations left.
Chris Lattner [Thu, 19 Jul 2007 00:42:40 +0000 (00:42 +0000)]
Fix a crasher that Neil reported: Sema::GetTypeForDeclarator should never
return a null type. If there is an error parsing the type, pick a new type
for error recovery purposes.
Steve Naroff [Wed, 18 Jul 2007 18:00:27 +0000 (18:00 +0000)]
First round of extended vector support. Here is an overview...
- added ocu_vector_type attribute, Sema::HandleOCUVectorTypeAttribute().
- added new AST node, OCUVectorType, a subclass of VectorType.
- added ASTContext::getOCUVectorType.
- changed ASTContext::convertToVectorType() to ASTContext::getVectorType(). This is
unrelated to extended vectors, however I was in the vicinity and it was on my todo list.
Added a FIXME to Sema::HandleVectorTypeAttribute to deal with converting complex types.
Bill Wendling [Tue, 17 Jul 2007 04:16:47 +0000 (04:16 +0000)]
Change dyn_cast for reference types to be more like pointers and not need the canonical type. Also fix so that we're not expecting a return value from a void function
Bill Wendling [Tue, 17 Jul 2007 03:52:31 +0000 (03:52 +0000)]
Fix references:
According to the spec (C++ 5p6[expr]), we need to adjust "T&" to
"T" before further analysis. We do this via the "implicit cast"
thingy.
Steve Naroff [Tue, 17 Jul 2007 00:58:39 +0000 (00:58 +0000)]
Convert UsualArithmeticConversions to return "void". Now that we synthesize ImplicitCastExpr's,
there is no compelling need to return the converted type. If both expression type's are arithmetic, then
both types will always be the same. If they aren't (for pointer/int types, say), then the
types will be different. The client is responsible for distinguishing...
Steve Naroff [Mon, 16 Jul 2007 22:23:01 +0000 (22:23 +0000)]
Remove the 2 QualType references to method UsualArithmeticConversions. Last week, I added these
to quickly fix a regression. Avoiding them entirely is a much cleaner solution. Clients of
UsualArithmeticConversions should simply call getType() on the expression to get the
converted type. In practice, only a small number of routines care about this.
Chris Lattner [Mon, 16 Jul 2007 22:05:22 +0000 (22:05 +0000)]
In the final step for preserving typedef info better in the AST, upgrade
isPointerType and isVectorType to only look through a single level of typedef
when one is present. For this invalid code:
typedef float float4 __attribute__((vector_size(16)));
typedef int int4 __attribute__((vector_size(16)));
typedef int4* int4p;
void test(float4 a, int4p result, int i) {
result[i] = a;
}
Steve Naroff [Mon, 16 Jul 2007 21:54:35 +0000 (21:54 +0000)]
Change DefaultFunctionArrayConversions and UsualUnaryConversions to return void. The caller
needs to query the expression for the type. Since both these functions guarantee the expression
contains a valid type, removed old/vacuous asserts (from code calling both of these routines).
Chris Lattner [Mon, 16 Jul 2007 06:55:01 +0000 (06:55 +0000)]
Make octal constant lexing use AdvanceToTokenCharacter to give more
accurate diagnostics. For test/Lexer/comments.c we now emit:
int x = 000000080; /* expected-error {{invalid digit}} */
^
constants.c:7:4: error: invalid digit '8' in octal constant
00080; /* expected-error {{invalid digit}} */
^
The last line is due to an escaped newline. The full line looks like:
int y = 0000\
00080; /* expected-error {{invalid digit}} */
Previously, we emitted:
constants.c:4:9: error: invalid digit '8' in octal constant
int x = 000000080; /* expected-error {{invalid digit}} */
^
constants.c:6:9: error: invalid digit '8' in octal constant
int y = 0000\
^
which isn't too bad, but the new way is better for the user,
regardless of whether there is an escaped newline or not.
All the other lexer-related diagnostics should switch over
to using AdvanceToTokenCharacter where appropriate. Help
wanted :).
Chris Lattner [Mon, 16 Jul 2007 06:48:38 +0000 (06:48 +0000)]
Add a new Preprocessor::AdvanceToTokenCharacter method which, given a sloc
specifying the start of a token and a logical (phase 3) character number,
returns a sloc representing the input character corresponding to it.
Chris Lattner [Mon, 16 Jul 2007 00:14:47 +0000 (00:14 +0000)]
Use the return value of isPointerType and isVectorType to significantly simplify
ParseArraySubscriptExpr. Notably, the new code doesn't have to think about
canonical types at all.
Chris Lattner [Sun, 15 Jul 2007 23:54:50 +0000 (23:54 +0000)]
Remove an extraneous QualType from CastExpr, it's type is always
the result type of the expr node.
Implement isIntegerConstantExpr for ImplicitCastExpr nodes the same
was as for CastExpr nodes.
Implement proper sign/zero extension as well as truncation and noop
conversion in the i-c-e evaluator. This allows us to correctly
handle i-c-e's like these:
Steve Naroff [Sun, 15 Jul 2007 02:02:06 +0000 (02:02 +0000)]
This is the final step/commit for implementing exlicit implicit casts. Unlike the
previous two checkins, which involved lot's of tedious refactoring, this checkin is nice and clean:-)
- Hacked UsualUnaryConversions, UsualArithmeticConversions, and DefaultFunctionArrayConversion
to create the AST node (using a helper function promoteExprToType).
- Added a setType method to Expr.
- Changed Expr::isIntegerConstantExpr to allow for the new node.
Chris Lattner [Sun, 15 Jul 2007 00:25:26 +0000 (00:25 +0000)]
Cache macro expander objects to avoid thrashing malloc in heavy expansion situations.
This doesn't significantly improve carbon.h, but it does speed up
INPUTS/macro_pounder_obj.c by 48%
Chris Lattner [Sat, 14 Jul 2007 22:46:43 +0000 (22:46 +0000)]
switch function-like macros from using a vector for their arguments to an
explicitly new'd array. The array never mutates once created, so a vector
is overkill.
Chris Lattner [Sat, 14 Jul 2007 22:15:50 +0000 (22:15 +0000)]
switch from using a vector to a smallvector for macro replacement tokens
This speeds up parsing carbon.h by 3.3% by avoiding some malloc traffic for
small macros.
Steve Naroff [Fri, 13 Jul 2007 23:32:42 +0000 (23:32 +0000)]
More changes related to implementing ImplicitCastExpr.
- Fixed a recent regression discovered by Keith Bauer (thanks!).
The fix involved adding (back) two arguments to UsualArithmeticConversions.
Without the reference arguments, no unary conversions were being passed back
to the caller. This had the effect of turning off the UsualUnaryConversions.
- Refactored CheckAssignmentConstraints into 3 functions. CheckAssignmentConstraints,
CheckSingleAssignmentConstraints, and CheckCompoundAssignmentConstraints.
- Changed the argument type of DefaultFunctionArrayConversion from QualType->Expr*&.
- Removed a bunch of casts in routines I was working on (cleanup).
- Fixed the visitor for ImplicitCastExpr (oops).
Steve Naroff [Fri, 13 Jul 2007 16:58:59 +0000 (16:58 +0000)]
Add (explicit) AST support for implicit casts. This should simplify the
code generator. Source translation tools can simply ignore this node.
- Added a new Expr node, ImplicitCastExpr.
- Changed UsualUnaryConversions/UsualArithmeticConversions to take references
to Expr *'s. This will allow these routines to instantiate the new AST node
and pass it back.
- Changed all clients of UsualUnary/UsualArithmetic (lot's of diff's).
- Changed some names in CheckConditionalOperands. Several variables where
only distinguished by their case (e.g. Cond, cond). Yuck (what was I thinking).
- Removed an old/crufty constructor in CastExpr (cleanup).
This check-in does not actually create the new AST node. I wanted to separate
the mechanical changes from the semantic changes. In addition, I need to
coordinate with Chris, since the semantic change will break the code generator.