Chris Lattner
c1410dc1e6
Change MacroArgs to allocate space for the unexpanded tokens immediately after
...
the MacroArgs object itself. This is a bit more efficient and will be even more
so shortly.
llvm-svn: 38756
2006-07-26 05:22:49 +00:00
Chris Lattner
7021657a0f
Implement a FIXME: don't copy token array into a token vector, instead, macroexpander should expand from an array directly.
...
llvm-svn: 38754
2006-07-26 03:50:40 +00:00
Chris Lattner
36b6e8134e
speed up a brutal macro-expansion torture test by about 30% (1.5 -> 1.0s)
...
by turning vectors of vectors into a single vector, reducing pressure on
malloc. This can still be improved.
llvm-svn: 38753
2006-07-21 06:38:30 +00:00
Chris Lattner
510ab61fd3
Add optimization for identifier##identifier -> identifier, the most common case of token pasting.
...
llvm-svn: 38747
2006-07-20 04:47:30 +00:00
Chris Lattner
538d7f3c27
Simplify "raw lexing mode" even further. Now the preprocessor is only called
...
into when a hard error is found. This simplifies logic and eliminates the need
for the preprocessor to know about raw mode.
llvm-svn: 38746
2006-07-20 04:31:52 +00:00
Chris Lattner
0f1f50517b
Simplify identifier lookup in raw mode, implementing Preprocessor/macro_fn_lparen_scan2.c.
...
llvm-svn: 38744
2006-07-20 04:16:23 +00:00
Chris Lattner
30a2fa14ae
Move LexingRawMode handling of file EOF out of the preprocessor into the
...
lexer. This makes more logical sense and also unbreaks the case when the
lexer hasn't been pushed onto the PP include stack. This is the case when
pasting identifiers. This patch implements macro_paste_bcpl_comment.c.
llvm-svn: 38736
2006-07-19 06:31:49 +00:00
Chris Lattner
2183a6e8f4
Make end-of-file handling much less recursive. This reduces the worst case
...
stack depth sampled by shark from ~34 to ~17 frames when preprocessing <iostream>.
llvm-svn: 38726
2006-07-18 06:36:12 +00:00
Chris Lattner
7667d0d942
Implement support for lexing from a pre-constructed token stream.
...
Use this support to implement function-like macro argument preexpansion.
This implements test/Preprocessor/macro_fn_preexpand.c
llvm-svn: 38724
2006-07-16 18:16:58 +00:00
Chris Lattner
2ada5d3890
More changes from formals -> actuals.
...
llvm-svn: 38717
2006-07-15 07:51:24 +00:00
Chris Lattner
ee8760b21b
Rename macroformalargs -> MacroArgs, as it represents the actual arguments,
...
not the formal arguments, to a macro.
llvm-svn: 38716
2006-07-15 07:42:55 +00:00
Chris Lattner
c653246bfb
Eliminate the IdentifierInfo::IsMacroArg flag.
...
llvm-svn: 38715
2006-07-15 06:55:18 +00:00
Chris Lattner
ecc39e9325
Change Lexer::Stringify to not add ""'s around the string.
...
llvm-svn: 38708
2006-07-15 05:23:31 +00:00
Chris Lattner
b94ec7b668
Add an API so that external clients can create strings in the scratch buffer.
...
llvm-svn: 38706
2006-07-14 06:54:10 +00:00
Chris Lattner
678c880a69
Move Preprocessor::isNextPPTokenLParen to Lexer::isNextPPTokenLParen, where
...
it more rightly belongs.
llvm-svn: 38702
2006-07-11 05:46:12 +00:00
Chris Lattner
3ebcf4e2cd
Change Preprocessor::SkippingContents into Lexer::LexingRawMode. Raw mode
...
is an intra-lexer property, not a inter-lexer property, so it makes sense
for it to be define here. It also makes no sense for macros, and allows us
to define it more carefully in the header.
While I'm at it, improve comments and structuring in Lexer.h
llvm-svn: 38701
2006-07-11 05:39:23 +00:00
Chris Lattner
69f88b883d
Fix a regression on Preprocessor/hash_space.c
...
llvm-svn: 38700
2006-07-11 05:07:29 +00:00
Chris Lattner
d8aee0e81b
Implement "lparen scanning" for lexer buffers, by making "skipping lexing"
...
completely reversible. This implements tests 3/4 of
test/Preprocessor/macro_fn_lparen_scan.c
llvm-svn: 38699
2006-07-11 05:04:55 +00:00
Chris Lattner
a12dd15b56
ext-warn on empty macro arguments if in pre-c99 mode
...
llvm-svn: 38697
2006-07-11 04:09:02 +00:00
Chris Lattner
afe603fa7d
Implement scanning-for-( more correctly. This implements
...
test/Preprocessor/macro_fn_lparen_scan.c, but is not yet complete.
Add some FIXME's about missing diagnostics on empty macro args. Improve some
comments.
llvm-svn: 38694
2006-07-11 04:02:46 +00:00
Chris Lattner
03f83485bd
Only do an expensive walk over the entire identifier table if the diagnostic
...
that needs it is enabled.
llvm-svn: 38690
2006-07-10 06:16:26 +00:00
Chris Lattner
3ce1d1aac9
Trivially expand macros like:
...
#define ENOMEMORYFORYOU ENOMEMORYFORYOU
llvm-svn: 38687
2006-07-09 01:00:18 +00:00
Chris Lattner
c239583433
Make trivial expansion detection more aggressive. Trivially expand macros
...
like: #define IS_BLAH() 1
llvm-svn: 38686
2006-07-09 00:57:04 +00:00
Chris Lattner
7818605f83
Read, remember, and validate the arguments provided the a function-style
...
macro invocation.
llvm-svn: 38685
2006-07-09 00:45:31 +00:00
Chris Lattner
815a1f97f6
Diagnose C99 6.10.3.2p1
...
llvm-svn: 38683
2006-07-08 20:48:04 +00:00
Chris Lattner
6e0d42c6f8
Add identifiers for macro arguments to MacroInfo, check for duplicates,
...
enhance macro equality testing to verify argument lists match.
llvm-svn: 38682
2006-07-08 20:32:52 +00:00
Chris Lattner
cefc768f5b
Start reading/validating the argument list for a function-like macro.
...
llvm-svn: 38681
2006-07-08 08:28:12 +00:00
Chris Lattner
21284dfdd1
Implement checking for macro equality, C99 6.10.3.2
...
llvm-svn: 38680
2006-07-08 07:16:08 +00:00
Chris Lattner
e8eef3207b
add infrastructure for warning if redef'd macro bodies differ, but don't
...
fully implement it.
Fix warning on #define __LINE__ to warn about redefinition, not #undef.
llvm-svn: 38679
2006-07-08 07:01:00 +00:00
Chris Lattner
8ff7199e4b
Warn about __VA_ARGS__ when used outside of a macro expansion
...
llvm-svn: 38678
2006-07-06 05:17:39 +00:00
Chris Lattner
bff18d5649
Diagnose erroneous macro definitions where a ## operator is at the start/end of the macro
...
llvm-svn: 38677
2006-07-06 04:49:18 +00:00
Chris Lattner
d3a15f7f4e
Add a fast-path in getSpelling for identifiers.
...
llvm-svn: 38672
2006-07-04 23:01:03 +00:00
Chris Lattner
ef9eae1c44
Change the Preprocessor::getSpelling interface to let it be zero-copy in
...
the common case.
llvm-svn: 38671
2006-07-04 22:33:12 +00:00
Chris Lattner
c79f6fb108
Rename IdentifierTokenInfo -> IdentifierInfo.
...
llvm-svn: 38650
2006-07-04 17:53:21 +00:00
Chris Lattner
a8654ca2cf
Eliminate MultipleIncludeOpt::ReadDirective and all calls to it. Any directives
...
that are lexed are made up of tokens, so the calls are just ugly and redundant.
Hook up the MIOpt for the #if case. PPCExpressions doesn't currently implement
the hook though, so we still don't handle #if !defined(X) with the MIOpt.
llvm-svn: 38649
2006-07-04 17:42:08 +00:00
Chris Lattner
3665f161ca
Implement the multiple-include file optimization.
...
llvm-svn: 38647
2006-07-04 07:26:10 +00:00
Chris Lattner
371ac8a9b7
Implement the automaton for recognizing files with controlling macros.
...
llvm-svn: 38646
2006-07-04 07:11:10 +00:00
Chris Lattner
d7dfa57efd
cleanup fixme's
...
llvm-svn: 38645
2006-07-04 04:50:35 +00:00
Chris Lattner
01d66cc891
Implement #ident and #sccs
...
llvm-svn: 38643
2006-07-03 22:16:27 +00:00
Chris Lattner
d7de629c32
Move a method inline
...
llvm-svn: 38639
2006-07-03 06:05:41 +00:00
Chris Lattner
a78a97e82f
#ifdef X, #ifndef X, and #if defined(X) all mark X as used.
...
llvm-svn: 38638
2006-07-03 05:42:18 +00:00
Chris Lattner
83913dde23
remove dead var
...
llvm-svn: 38635
2006-07-03 05:31:31 +00:00
Chris Lattner
f88c53a02f
Fix test/Preprocessor/_Pragma-syshdr2.c.
...
llvm-svn: 38634
2006-07-03 05:26:05 +00:00
Chris Lattner
13044d942d
Implement -Wunused-macros functionality.
...
llvm-svn: 38632
2006-07-03 05:16:44 +00:00
Chris Lattner
44f8a66bcc
Fix test/Preprocessor/macro_defined.c, factor some code.
...
llvm-svn: 38627
2006-07-03 01:27:27 +00:00
Chris Lattner
aaf09115c4
Implement a FIXME: reject '#define defined'.
...
llvm-svn: 38625
2006-07-03 01:17:59 +00:00
Chris Lattner
e3e81ea8aa
Refactor some code into a new Lexer::Stringify method.
...
llvm-svn: 38624
2006-07-03 01:13:26 +00:00
Chris Lattner
0766e592ce
Implement a FIXME: correctly stringify filenames generated by __LINE__.
...
llvm-svn: 38622
2006-07-03 01:07:01 +00:00
Chris Lattner
4d5e1a72f4
Classify fixme's
...
llvm-svn: 38621
2006-07-03 01:01:29 +00:00
Chris Lattner
98a5312478
Give tokens expanded from _Pragma directives correct source locations.
...
This implements test/Preprocessor/_Pragma-location.c
llvm-svn: 38619
2006-07-02 23:00:20 +00:00