Commit Graph

27 Commits

Author SHA1 Message Date
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 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 a7e2e74cef Avoid testing / ## * in the lexer. This will cause an unhelpful error message
to be emitted from the lexer.  This fixes macro_paste_c_block_comment.c

llvm-svn: 38737
2006-07-19 06:32:35 +00:00
Chris Lattner e8dcfef324 Fix test/Preprocessor/macro_paste_spacing.c
llvm-svn: 38734
2006-07-19 05:45:55 +00:00
Chris Lattner 01ecf835c2 Implement basic token pasting (## operator). This implements
test/Preprocessor/macro_paste_simple.c and macro_paste_bad.c.  There are
several known bugs still.

llvm-svn: 38733
2006-07-19 05:42:48 +00:00
Chris Lattner 7e2e669080 Handle really simple expansion of ## formals. Do not handle the empty case
yet though.

llvm-svn: 38729
2006-07-19 03:51:26 +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 203b4568e2 Implement basic argument substitution. This implements
test/Preprocessor/macro_fn_disable_expand.c

llvm-svn: 38720
2006-07-15 21:07:40 +00:00
Chris Lattner 7c58149107 Clarify assertion
llvm-svn: 38718
2006-07-15 07:56:31 +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 6016169cb8 The leading space flag of a stringized string matches that of the # operator.
llvm-svn: 38713
2006-07-15 06:48:02 +00:00
Chris Lattner c783d1dff9 Implement the microsoft charize extension #@
llvm-svn: 38712
2006-07-15 06:11:25 +00:00
Chris Lattner f2781509f9 Add a comment giving an example of the error
llvm-svn: 38710
2006-07-15 05:27:44 +00:00
Chris Lattner 0707bd3042 Implement stringification.
llvm-svn: 38709
2006-07-15 05:23:58 +00:00
Chris Lattner b935d8cd90 Set up infrastructure for function-like macro expansion with preexpansion
stringizing, etc.

llvm-svn: 38707
2006-07-14 06:54:44 +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 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 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 c673f905d8 Implement the __TIME__ and __DATE__ builtin macros.
llvm-svn: 38597
2006-06-30 06:10:41 +00:00
Chris Lattner 67b07cb6fe Implement Preprocessor/macro_expandloc.c by giving the optimized macro
expansion case a correct source location.

llvm-svn: 38580
2006-06-26 02:03:42 +00:00
Chris Lattner 30709b038d Implement a new type of FileID: FileIDInfo::MacroExpansion. For tokens that
came from a macro expansion, this allows us to keep track of both where the
character data came from and where the logical position of the token is (at
the expansion site).  This implements Preprocessor/indent_macro.c, and
reduces the number of cpp iostream -E diffs vs GCC from 2589 to 2297.

llvm-svn: 38557
2006-06-21 03:01:55 +00:00
Chris Lattner 50b497e072 Rename LexerToken::getSourceLocation -> getLocation
llvm-svn: 38553
2006-06-18 16:32:35 +00:00
Chris Lattner d01e291332 Make a fundamental change to the way we represent the location of LexerToken's.
Now, instead of keeping a pointer to the start of the token in memory, we keep the
start of the token as a SourceLocation node.  This means that each LexerToken knows
the full include stack it was created with, and means that the LexerToken isn't
reliant on a "CurLexer" member to be around (lexer tokens would previously go out of
scope when their lexers were deallocated).

This simplifies several things, and forces good cleanup elsewhere.  Now the
Preprocessor is the one that knows how to dump tokens/macros and is the one that
knows how to get the spelling of a token (it has all the context).

llvm-svn: 38551
2006-06-18 16:22:51 +00:00
Chris Lattner cb28334ea4 Remove manual conditional error handling code.
llvm-svn: 38540
2006-06-18 06:48:37 +00:00
Chris Lattner 22eb972f38 Initial checkin of c-language parser
llvm-svn: 38539
2006-06-18 05:43:12 +00:00