Chris Lattner [Mon, 23 Jul 2007 06:09:34 +0000 (06:09 +0000)]
change the concatenation avoidance algorithm to be partially table-driven
and avoid computing the spelling of tokens when not needed. This speeds
up -E on 447.dealII by 2.2%
Chris Lattner [Mon, 23 Jul 2007 04:56:47 +0000 (04:56 +0000)]
implement a missing feature in the #include handler, where
it did not handle <xyz> headers coming from macro expansions.
This requires special treatment, as the include name is lexed
as multiple tokens, which require reassembly before processing.
Chris Lattner [Sun, 22 Jul 2007 22:50:09 +0000 (22:50 +0000)]
fix a bug getting the spelling of an identifier token
that required cleaning. If the token required cleaning,
don't include the cleaned tokens in the returned length.
Chris Lattner [Sun, 22 Jul 2007 22:33:25 +0000 (22:33 +0000)]
no need to avoid pasting >* It can't form ->*, because we know the previous
token was not -> and if the token before it was -, the - and > would avoid pasting.
Chris Lattner [Sun, 22 Jul 2007 20:11:46 +0000 (20:11 +0000)]
Switch TargetInfo::getTargetDefines from using an std::map<std::string, ...> to using
a llvm::StringMap. This dramatically reduces the startup time of the preprocessor,
speeding up -Eonly on xalankbmk by 2.2%.
Chris Lattner [Sun, 22 Jul 2007 18:44:36 +0000 (18:44 +0000)]
Change hte lexer to start a start pointer to the underlying
memorybuffer instead of a pointer to the memorybuffer itself. This
reduces coupling and eliminates a pointer dereference on a hot path.
This speeds up -Eonly on 483.xalancbmk by 2.1%
Chris Lattner [Sun, 22 Jul 2007 07:28:00 +0000 (07:28 +0000)]
Implement a simple cache in headersearch. This speeds up
preprocessing 483.xalancbmk by about 10%, reducing the number
of file lookup queries from 2139411 to 199466 (over 10x)
Chris Lattner [Sun, 22 Jul 2007 06:05:44 +0000 (06:05 +0000)]
when running in -E mode on multiple files, there is no reason to accumulate
fileid's and macroid's across files. Clearing between files keeps the tables
smaller and slightly speeds up compilation.
Chris Lattner [Sun, 22 Jul 2007 01:16:55 +0000 (01:16 +0000)]
Fix a really subtle bug in the macro expander caching code, where
redefinition of a macro could cause invalid memory to be deleted.
Found preprocessing 253.perlbmk.
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: