Commit Graph

59 Commits

Author SHA1 Message Date
Chris Lattner 98c1f7cfde Switch lexer/pp over to new Token::is/isNot api
llvm-svn: 42799
2007-10-09 18:02:16 +00:00
Chris Lattner c43ddc84a3 improve layering:
Now instead of IdentifierInfo knowing anything about MacroInfo,
only the preprocessor knows.  This makes MacroInfo truly private
to the Lex library (and its direct clients) instead of being 
accessed in the Basic library.

llvm-svn: 42727
2007-10-07 08:44:20 +00:00
Chris Lattner 9c724c48ea 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.

llvm-svn: 40380
2007-07-22 01:16:55 +00:00
Chris Lattner 146762e7a4 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.

llvm-svn: 40105
2007-07-20 16:59:19 +00:00
Chris Lattner 77e9de50a1 simplify the lexer ctor to take a SLoc instead of a sloc and a redundant buffer*.
llvm-svn: 40104
2007-07-20 16:52:03 +00:00
Chris Lattner dc5c055fd1 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.

llvm-svn: 40103
2007-07-20 16:37:10 +00:00
Chris Lattner 24dbee71ab Fix a stringizing bug that Neil noticed. We should preprocess this:
#define t(x) #x
t(a
c)

to "a c", not "ac".

llvm-svn: 40060
2007-07-19 16:11:58 +00:00
Chris Lattner b1711e8485 remove obsolete comment.
llvm-svn: 39868
2007-07-15 06:46:25 +00:00
Chris Lattner 3fc74e2468 Change SourceManager::getInstantiationLoc to take virtual locations, doing its
virtual->physical mapping explicitly.

llvm-svn: 39867
2007-07-15 06:35:27 +00:00
Chris Lattner c02c4abe5b 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%

llvm-svn: 39864
2007-07-15 00:25:26 +00:00
Chris Lattner f40fe99118 expose an iterator interface to getReplacementTokens instead of the datastructure itself.
llvm-svn: 39860
2007-07-14 22:11:41 +00:00
Chris Lattner 23b7eb677d Finally bite the bullet and make the major change: split the clang namespace
out of the llvm namespace.  This makes the clang namespace be a sibling of
llvm instead of being a child.

The good thing about this is that it makes many things unambiguous.  The
bad things is that many things in the llvm namespace (notably data structures
like smallvector) now require an llvm:: qualifier.  IMO, libsystem and libsupport
should be split out of llvm into their own namespace in the future, which will fix
this issue.

llvm-svn: 39659
2007-06-15 23:05:46 +00:00
Chris Lattner 57dd8360f6 implement FIXME: replace use of alloca with use of SmallVector.
llvm-svn: 39102
2006-11-03 07:45:04 +00:00
Chris Lattner 7cee11f078 Export the ASTBuilder class from the AST module.
llvm-svn: 39095
2006-11-03 06:42:29 +00:00
Chris Lattner 8c2048710d Rename LexerToken methods to be more consistent.
llvm-svn: 38969
2006-10-14 05:19:21 +00:00
Chris Lattner d3e9895b9a Initial support for semantic analysis and AST building for StringExpr nodes.
llvm-svn: 38960
2006-10-06 05:22:26 +00:00
Chris Lattner 95a06b34f7 Simplify implementation of varargs macros by adding the __VA_ARGS__ token
to the formal argument list of a C99 varargs macro.

llvm-svn: 38800
2006-07-30 08:40:43 +00:00
Chris Lattner 07560ed0cf Fix precedence bug
llvm-svn: 38793
2006-07-29 07:26:48 +00:00
Chris Lattner f76e62ecad Implement support for #__VA_ARGS__
llvm-svn: 38791
2006-07-29 07:14:41 +00:00
Chris Lattner d97d2e780c Fix a crash on Preprocessor/macro_paste_none.c
llvm-svn: 38787
2006-07-29 06:44:29 +00:00
Chris Lattner 775d832110 Implement the GNU comma swallowing extension. This implements
test/Preprocessor/macro_fn_comma_swallow.c

llvm-svn: 38780
2006-07-29 04:39:41 +00:00
Chris Lattner 479b0af31d Improve placemarker handling, implementing Preprocessor/macro_fn_placemarker.c
llvm-svn: 38778
2006-07-29 04:16:20 +00:00
Chris Lattner 21c8b8f71e Implement support for __VA_ARGS__, allowing test/Preprocessor/macro_fn_varargs_iso.c
to pass.

llvm-svn: 38776
2006-07-29 04:04:22 +00:00
Chris Lattner f3f1c709cf Use a continue to avoid indentation of a bunch of code
llvm-svn: 38762
2006-07-28 05:10:36 +00:00
Chris Lattner a9dc597fca Implement pasting of arguments that expand to no tokens. This handles the
C99 "placemarker" concept.

llvm-svn: 38761
2006-07-28 05:07:04 +00:00
Chris Lattner b57aa46e41 Switch ExpandFunctionArguments to use a smallvector instead of a vector,
speeding up my macro expansion torture test from .75s to .5s (33%!)

llvm-svn: 38758
2006-07-27 03:42:15 +00:00
Chris Lattner 7a4af3b73d Change Preprocessor::ReadFunctionLikeMacroArgs to use a SmallVector to lex
argument tokens into instead of a real vector.  This avoids some malloc
traffic in common cases.  In an "abusive macro expansion" testcase, this
reduced -Eonly time by 25%.

llvm-svn: 38757
2006-07-26 06:26:52 +00:00
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 6fc08bc77d Add a new getArgLength method and refactor some code to use it
llvm-svn: 38755
2006-07-26 04:55:32 +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 08ba4c015f fix obvious bug that caused Preprocessor/macro_paste_bad.c to fail.
llvm-svn: 38748
2006-07-20 04:52:59 +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 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