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
a0d9bf4e83
Fix message in assert to be more accurate.
...
llvm-svn: 38732
2006-07-19 05:42:09 +00:00
Chris Lattner
f918bf71ef
update comment
...
llvm-svn: 38731
2006-07-19 05:01:18 +00:00
Chris Lattner
da63bcdc03
Simplify this by using a higher-level method.
...
llvm-svn: 38730
2006-07-19 04:36:03 +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
c653246bfb
Eliminate the IdentifierInfo::IsMacroArg flag.
...
llvm-svn: 38715
2006-07-15 06:55:18 +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
2b271db205
Lex the microsoft 'charize' extension.
...
llvm-svn: 38711
2006-07-15 05:41:09 +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
ecc39e9325
Change Lexer::Stringify to not add ""'s around the string.
...
llvm-svn: 38708
2006-07-15 05:23:31 +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
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
041bef8b32
The lexer should not warn about stray characters, it should just return
...
tok::unknown tokens. This fixes test/Lexer/unknown-char.c
llvm-svn: 38703
2006-07-11 05:52:53 +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
eb54b5973e
Add simple optimization: check for (and skip) spaces and tabs immediately
...
before lexing a token. This speeds the common case where tokens are
separated by small amount of whitespace. This makes a slight but
reproducible positive effect lexing a preprocessed carbon.h.
llvm-svn: 38691
2006-07-10 06:34:27 +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
d0a96ba38a
Add a simple but useful optimization for identifier lookup. Each time we
...
query the hash table, when we look up an identifier that isn't at the head
of it's bucket's list, move it there. This reduces the number of list
traversals in the common case where identifiers are used in bursts.
llvm-svn: 38689
2006-07-10 06:10:51 +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
27746e476a
Fix Preprocessor/macro_space.c, which failed because the ! token had
...
identifier info incorrectly set.
llvm-svn: 38674
2006-07-05 00:07:54 +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
a3f827e0a6
add a comment explaining why this is written funny
...
llvm-svn: 38670
2006-07-04 22:22:45 +00:00
Chris Lattner
0e1cf1f588
Fix indentation
...
llvm-svn: 38655
2006-07-04 18:53:52 +00:00
Chris Lattner
b9d90f709e
Detect expressions semantically equivalent to !defined(X) for the multiple-include
...
optimization.
llvm-svn: 38654
2006-07-04 18:32:03 +00:00
Chris Lattner
e3519cc948
Change EvaluateValue/EvaluateDirectiveSubExpr to be static functions in
...
PPExpressions.cpp instead of methods.
llvm-svn: 38652
2006-07-04 18:11:39 +00:00
Chris Lattner
8096542744
refactor code a little, no functionality change
...
llvm-svn: 38651
2006-07-04 18:03:19 +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