Commit Graph

325 Commits

Author SHA1 Message Date
Chris Lattner 86054a9634 Diagnostics relating to computation of values should only be produced if an
expression is live.  For example:
#if 0 ? 124/0 : 42

should cause no error.

This implements test/Preprocessor/expr_liveness.c

llvm-svn: 39397
2007-04-10 05:26:38 +00:00
Chris Lattner f8a0b0fa50 Add support for character constants in PP expressions, like:
#if 'a'

llvm-svn: 39393
2007-04-05 06:58:56 +00:00
Chris Lattner 2f5add6272 Implement support for performing semantic analysis of character literals.
llvm-svn: 39390
2007-04-05 06:57:15 +00:00
Chris Lattner a9eac7ff44 Correctly represent and propagate signedness information in preprocessor
constant expressions.  This allows us to emit this diagnostic:

t.c:5:5: warning: integer constant is so large that it is unsigned
#if 12345678901234567890
    ^

And makes constant evaluation fully correct, but we do not yet detect and
warn about integer overflow.

This patch requires cvs up'ing the main llvm tree to get the APSInt class,
but no libraries need to be rebuilt there.

llvm-svn: 39388
2007-04-05 05:24:00 +00:00
Chris Lattner 6df7975ae6 minor cleanups. The major missing piece is tracking:
* signedness of values
 * overflow of intermediate computations.

llvm-svn: 39387
2007-04-04 06:54:19 +00:00
Chris Lattner 531efa43d8 Ah, this is already correctly rejected!
llvm-svn: 39386
2007-04-04 06:49:26 +00:00
Chris Lattner ce5dc8a6b4 Switch PPExpression parsing to be in terms of APInt's whose widths are properly
sized to the target's intmax_t.  This also allows us to emit diagnostic like:

t.c:11:5: warning: integer constant is too large for its type
#if 18446744073709551616  // 2^64
    ^
t.c:15:5: warning: integer constant is too large for its type
#if 18446744073709551617  // 2^64-1
    ^

llvm-svn: 39385
2007-04-04 06:46:55 +00:00
Chris Lattner 871b4e101c Minor enhancements to GetIntegerValue(APInt):
* Detect overflow correctly.  When it occurs, return the truncated value.
  * Add fixme for radix analysis.

llvm-svn: 39382
2007-04-04 06:36:34 +00:00
Chris Lattner 5b743d3801 Add some really simplistic code for turning a ppnumber into an APInt. Much
improvement is needed!

llvm-svn: 39381
2007-04-04 05:52:58 +00:00
Chris Lattner 23d890337b Specify an initial size for StringMap.
llvm-svn: 39378
2007-04-03 22:14:25 +00:00
Steve Naroff f1e53698a4 Bug #:
Submitted by:
Reviewed by:

Type Checking...round 2. This checkin "breaks" parsing carbon.h. I imagine
that this will be true for the next week or so. Nevertheless, this round of
changes includes the following:

- Hacked various Expr classes to pass the appropriate TypeRef. Still have
a few more classes to touch.
- Implement type checking for ParseArraySubscriptExpr and ParseMemberReferenceExpr.
- Added a debug hook to derive the class name for Stmt/Expr nodes. Currently a
linear search...could easily optimize if important.
- Changed the name of TaggedType->TagType. Now we have TagType and TagDecl (which
are easier to remember).
- Fixed a bug in StringLiteral conversion I did a couple weeks ago. hadError was
not initialized (oops).
- changed Sema::Diag to return true. This streamlines the type checking code
considerably.
- Added many diagnositics.

This should be it!

llvm-svn: 39361
2007-03-23 22:27:02 +00:00
Steve Naroff 4f88b3113e Bug #:
Submitted by:
Reviewed by:
Move string literal parsing from Sema=>LiteralSupport. This consolidates
all the quirky parsing code within the Lexer subsystem (yeah!). This
simplifies Sema and (more importantly) allows future parsers
(i.e. subclasses of Action) to benefit from this code.

llvm-svn: 39354
2007-03-13 22:37:02 +00:00
Steve Naroff f2fb89e759 Bug #:
Submitted by:
Reviewed by:
Misc. cleanup/polish of NumericLiteralParser and it's two clients, the
C preprocessor and AST builder...

llvm-svn: 39353
2007-03-13 20:29:44 +00:00
Steve Naroff 451d8f1626 Bug #:
Submitted by:
Reviewed by:
-Converted the preprocessor to use NumericLiteralParser.
-Several minor changes to LiteralSupport interface/implementation.
-Added an error diagnostic for floating point usage in pp expr's.

llvm-svn: 39352
2007-03-12 23:22:38 +00:00
Steve Naroff 09ef474197 Bug #:
Submitted by:
Reviewed by:
Moved numeric literal support from SemaExpr.cpp to LiteralSupport.[h,cpp]
in Lex. This will allow it to be used by both Sema and Preprocessor (and
should be the last major refactoring of this sub-system).. Over
time, it will be reused by anyone implementing an actions module (i.e.
any subclass of llvm::clang::Action. Minor changes to IntegerLiteral in Expr.h.
More to come...

llvm-svn: 39351
2007-03-09 23:16:33 +00:00
Chris Lattner b055f2ddfc switch to using iterators instead of stringmap visitors.
llvm-svn: 39336
2007-02-11 08:19:57 +00:00
Chris Lattner 54d032bb76 CStringMap -> StringMap.
llvm-svn: 39334
2007-02-08 19:24:25 +00:00
Chris Lattner 34d1f5a8de adjust to CStringMap interface change.
llvm-svn: 39333
2007-02-08 19:08:49 +00:00
Chris Lattner 9561a0b3e7 Add support for target-independent builtin functions (like __builtin_abs),
whose decl objects are lazily created the first time they are referenced.
Builtin functions are described by the clang/AST/Builtins.def file, which
makes it easy to add new ones.

This is missing two important pieces:
1. Support for the rest of the gcc builtins.
2. Support for target-specific builtins (e.g. __builtin_ia32_emms).

Just adding this builtins reduces the number of implicit function definitions
by 6, reducing the # diagnostics from 550 to 544 when parsing carbon.h.

I need to add all the i386-specific ones to eliminate several hundred more.
ugh.

llvm-svn: 39327
2007-01-28 08:20:04 +00:00
Chris Lattner 3e7592ea78 Add support for -fno-operator-names, patch by Bill.
llvm-svn: 39245
2006-12-04 07:48:37 +00:00
Chris Lattner 652c16924e Produce a nice error message for '#define and' in C++. Patch by Bill!
llvm-svn: 39218
2006-11-21 23:47:30 +00:00
Chris Lattner 2bb8a95389 eliminate string compares when checking for the 'defined' token.
llvm-svn: 39216
2006-11-21 22:24:17 +00:00
Chris Lattner 5b9f4891d7 Add support for C++ operator keywords. Patch by Bill Wendling.
llvm-svn: 39214
2006-11-21 17:23:33 +00:00
Chris Lattner b352e3edb5 Change KeepComments/KeepMacroComments modes to be facets of the preprocessor
state, not aspects of the language standard being parsed.

llvm-svn: 39209
2006-11-21 06:17:10 +00:00
Chris Lattner ad7cdd37b3 simplify the Preprocessor ctor.
llvm-svn: 39208
2006-11-21 06:08:20 +00:00
Chris Lattner b8d6d5a81d Formalize preprocessor callbacks together into a PPCallbacks structure, instead
of having a loose collection of function pointers.  This also allows clients to
maintain state, and reduces the size of the Preprocessor.h interface.

llvm-svn: 39203
2006-11-21 04:09:30 +00:00
Chris Lattner c95c8f2356 Fix a bug
llvm-svn: 39128
2006-11-05 07:59:22 +00:00
Chris Lattner cf6bc66421 silence some warnings when asserts are disabled.
llvm-svn: 39127
2006-11-05 07:59:08 +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 9f6604fa60 Add altivec version of block comment skipping code.
llvm-svn: 39093
2006-10-30 20:01:22 +00:00
Chris Lattner c07ba1fe2f Refactor the paths used for checking and getting the spelling of #include
filenames (and also '#pragma GCC dependency' of course).  Now, assuming
no cleaning is needed, we can go all the way from lexing the filename to
doing filename lookups with no mallocs.  This speeds up user PP time from
0.077 to 0.075s for Cocoa.h (2.6%).

llvm-svn: 39092
2006-10-30 05:58:32 +00:00
Chris Lattner b8b94f1e9b Make Preprocessor::LookupFile take a character range instead of a string.
This avoids some copying in its clients.

llvm-svn: 39091
2006-10-30 05:38:06 +00:00
Chris Lattner 7cdbad945d Push strings out of the HeaderSearch interface, it now deals solely with
character ranges.

llvm-svn: 39090
2006-10-30 05:33:15 +00:00
Chris Lattner ee7bf89cd6 Change framework cache map from map to CStringMap. This speeds up PP user
time on Cocoa.h from 0.078 to 0.077s.

llvm-svn: 39089
2006-10-30 05:19:23 +00:00
Chris Lattner b201d9b13d Eliminate string use in DoFrameworkLookup. This speeds up pp of Cocoa.h
marginally from 0.079 to 0.078s.

llvm-svn: 39088
2006-10-30 05:09:49 +00:00
Chris Lattner cf8ddac4bc Use SmallString instead of string in HeaderSearch::LookupFile. This avoids
malloc traffic, speeding up user time preprocessing Carbon.h 5% (0.083s to
0.079s).

llvm-svn: 39087
2006-10-30 04:42:33 +00:00
Chris Lattner 43fd42e4d9 Wean LookupSubframeworkHeader off std::strings, use the new SmallString
class instead.  SmallString allows to code to avoid hitting malloc in
the normal case (or will, when some other stuff is converted over).

llvm-svn: 39084
2006-10-30 03:40:58 +00:00
Chris Lattner da933aac0c remove some temporary testing code
llvm-svn: 39080
2006-10-29 23:49:15 +00:00
Chris Lattner 2b9e19be87 Pull the string hashtable out of the IdentifierTable, moving into LLVM's
libsupport.  Now it can be used for other things besides identifier hashing.

llvm-svn: 39079
2006-10-29 23:43:13 +00:00
Chris Lattner ec659fce46 move memory allocation abstraction stuff out into LLVM's libsupport
llvm-svn: 39078
2006-10-29 22:09:44 +00:00
Chris Lattner 3bc804ed3d genericize IdentifierInfo interface to make it work more naturally.
llvm-svn: 39076
2006-10-28 23:46:24 +00:00
Chris Lattner bcb416bbd5 Implement test/Preprocessor/comment_save_if.c
llvm-svn: 39069
2006-10-27 05:43:50 +00:00
Chris Lattner 9916c5ca7e Remove GNU C++ min/max operator extension support, they have been removed
from gcc mainline.

llvm-svn: 39067
2006-10-27 05:24:37 +00:00
Chris Lattner ffda89611f Change DirectoryEntry::getName() to return a const char *
llvm-svn: 39066
2006-10-27 05:15:55 +00:00
Chris Lattner 480434865d change FileEntry::getName to return a const char*.
llvm-svn: 39065
2006-10-27 05:12:36 +00:00
Chris Lattner 56bdb9a9a1 Remove identifier length field from IdentifierInfo, it is now dead.
llvm-svn: 39063
2006-10-27 05:06:38 +00:00
Chris Lattner a883116ece fix bug reprobing.
llvm-svn: 39062
2006-10-27 04:54:47 +00:00
Chris Lattner 089e51923e remove todo
llvm-svn: 39061
2006-10-27 04:53:38 +00:00
Chris Lattner aded4a977d Implement an sse2 version of the block comment scanner.
llvm-svn: 39060
2006-10-27 04:42:31 +00:00
Chris Lattner 6cc3e36cd7 Speed up block comment skipping by 35%.
llvm-svn: 39059
2006-10-27 04:12:35 +00:00
Chris Lattner f2e3ac3b54 reimplement identifier hash table in terms of a probed table instead of a chained
table.  This is about 25% faster for identifier lookup.  This also implements
resizing of the hash table.

llvm-svn: 39058
2006-10-27 03:59:10 +00:00
Chris Lattner 341fd06d3c Use the full hash as a filter to reduce # strcmps
llvm-svn: 39057
2006-10-26 05:18:38 +00:00
Chris Lattner 893f272c39 Track the full (not mod the hash table size) hash value for each token.
This lets us find interesting properties of the hash distribution.

llvm-svn: 39056
2006-10-26 05:12:31 +00:00
Chris Lattner 05646c7f0e Fix these to allow clang to be in any dir.
llvm-svn: 39055
2006-10-26 04:56:55 +00:00
Chris Lattner b19f796e97 llvm has no EH by default, no need for these flags.
llvm-svn: 39047
2006-10-25 05:09:05 +00:00
Chris Lattner 0ba3dc4ec3 Start removing LexerToken from the actions interface.
llvm-svn: 39043
2006-10-25 03:38:23 +00:00
Chris Lattner 3c98fd3af3 Switch to using a bitwise and instead of modulus.
llvm-svn: 39038
2006-10-22 17:48:27 +00:00
Chris Lattner 07b019a1bc add #include
llvm-svn: 39034
2006-10-22 07:28:56 +00:00
Chris Lattner 5ed76da296 Implement framework filesystem caching.
llvm-svn: 39031
2006-10-22 07:24:13 +00:00
Chris Lattner 641a0be31b count # framework lookups
llvm-svn: 39026
2006-10-20 06:23:14 +00:00
Chris Lattner a4271e4a51 rename
llvm-svn: 39024
2006-10-20 06:13:26 +00:00
Chris Lattner 5c683b2b4b Fix a regression introduced when adding subframework support
llvm-svn: 39022
2006-10-20 05:12:14 +00:00
Chris Lattner 62aa0d4c9f Implement test/Preprocessor/macro_arg_keyword.c
llvm-svn: 39021
2006-10-20 05:08:24 +00:00
Chris Lattner 577377e847 Speed up [sub]framework searching
llvm-svn: 39017
2006-10-20 04:55:45 +00:00
Chris Lattner 63dd32b656 Implement subframework lookup
llvm-svn: 39015
2006-10-20 04:42:40 +00:00
Chris Lattner 25e0d54a0e Move keyword setup from the preprocessor into the IdentifierTable class.
llvm-svn: 39014
2006-10-18 06:07:05 +00:00
Chris Lattner 59a9ebdb17 refactor header searching stuff out of the main Preprocessor object into
it's own HeaderSearch object.  This makes Preprocessor simpler and easier
to understand.

llvm-svn: 39012
2006-10-18 05:34:33 +00:00
Chris Lattner ff777c38dc silence warning, add hacky patch for framework lookup
llvm-svn: 39011
2006-10-18 04:03:13 +00:00
Chris Lattner 720f2700b1 Make the identifier table track objc keywords
llvm-svn: 39003
2006-10-17 04:03:44 +00:00
Chris Lattner 87d3bec423 Make preprocessor keywords like 'define' first class citizens in the
IdentifierTable, instead of making them resort to strcmp'ing.

llvm-svn: 39002
2006-10-17 03:44:32 +00:00
Chris Lattner dd0b7cbf0b Oversight: fixes test/Lexer/number.c
llvm-svn: 38998
2006-10-17 02:53:51 +00:00
Chris Lattner 6e5b2a084e ignore '#line' and '# 123' for now.
llvm-svn: 38997
2006-10-17 02:53:32 +00:00
Chris Lattner 063400e46e Implement the #define_other_target directive.
llvm-svn: 38984
2006-10-14 19:54:15 +00:00
Chris Lattner 81278c6356 Implement the #define_target preprocessor directive.
llvm-svn: 38980
2006-10-14 19:03:49 +00:00
Chris Lattner 02dffbda3b Write up TargetInfo so that use of wchar_t strings results in a warning if
used in a target set where the size is not identical.

llvm-svn: 38975
2006-10-14 07:50:21 +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 6d998556de Fix precedence problem
llvm-svn: 38809
2006-08-04 06:11:48 +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 273ddd5c57 The optimized case has to treat __VA_ARGS__ as an argument. This fixes
test/Preprocessor/macro_rescan_varargs.c

llvm-svn: 38795
2006-07-29 07:33:01 +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 457fc15bc5 Implement comment saving mode: the -C and -CC options.
llvm-svn: 38783
2006-07-29 06:30:25 +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 02f1f4f28b Fix a bug in previous commit
llvm-svn: 38774
2006-07-29 03:52:46 +00:00
Chris Lattner 6d9f8ed3b6 No need for explicit underscore anymore.
llvm-svn: 38773
2006-07-29 03:52:06 +00:00
Chris Lattner 7e37483f14 Poison and unpoison __VA_ARGS__ when appropriate
llvm-svn: 38770
2006-07-29 03:46:57 +00:00
Chris Lattner e7a5130dff If the varargs token is missing, add an empty argument to represent it. This
fixes Preprocessor/macro_fn_varargs_named.c

llvm-svn: 38769
2006-07-29 01:25:12 +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 6e4bf523e6 Implement C99 6.10.3.4p2, testcase here: Preprocessor/macro_disable3.c.
llvm-svn: 38760
2006-07-27 06:59:25 +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 a5f4c882e2 disable malformed string/character errors when in raw mode. This fixes
test/Lexer/badstring_in_if0.c

llvm-svn: 38751
2006-07-20 06:08:47 +00:00
Chris Lattner 5a78a02ea2 If an invalid string or character is read, return the invalid part as a tok::unknown token.
llvm-svn: 38749
2006-07-20 06:02:19 +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 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 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 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 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 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