Commit Graph

356 Commits

Author SHA1 Message Date
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 564f478595 switch function-like macros from using a vector for their arguments to an
explicitly new'd array.  The array never mutates once created, so a vector
is overkill.

llvm-svn: 39862
2007-07-14 22:46:43 +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 a3834341c5 split function-like and object-like macro body parsing to make the
code more obvious.

llvm-svn: 39859
2007-07-14 21:54:03 +00:00
Chris Lattner f9aba2c2b4 remove use of alloca.
llvm-svn: 39815
2007-07-13 17:10:38 +00:00
Gabor Greif 441b3d47be Solaris needs an included header for alloca
llvm-svn: 39797
2007-07-13 08:21:39 +00:00
Steve Naroff 97b9e91eb7 Bug #:
Submitted by:
Reviewed by:
Added primitive support for 32-bit floating point literals.

llvm-svn: 39719
2007-07-09 23:53:58 +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 53621a535d Implement support for formal arguments. We can now compile this:
int test(int X, short Y, float Z) {
  return (int)(X*Y+Z);
}

to:

define i32 @test(i32 %X, i16 %Y, float %Z) {
entry:
        %promote = sext i16 %Y to i32           ; <i32> [#uses=1]
        %mul = mul i32 %promote, %X             ; <i32> [#uses=1]
        %promote3 = sitofp i32 %mul to float            ; <float> [#uses=1]
        %add = add float %promote3, %Z          ; <float> [#uses=1]
        %conv = fptosi float %add to i32                ; <i32> [#uses=1]
        ret i32 %conv
}

with:

$ clang -emit-llvm t.c | llvm-as | opt -std-compile-opts | llvm-dis

llvm-svn: 39652
2007-06-13 20:44:40 +00:00
Steve Naroff a8fd973aa0 Bug #:
Submitted by:
Reviewed by:
Implement semantic analysis for vector_size attribute!
We now produce the following diagnostics...

[administrators-powerbook59:~/llvm/tools/clang] admin% ../../Debug/bin/clang vector.c
vector.c:2:29: error: attribute requires precisely 1 argument
typedef int __attribute__(( vector_size )) tVecp;
                            ^
vector.c:7:32: error: attribute requires precisely 1 argument
extern int foo __attribute__(( vector_size ));
                               ^
vector.c:8:34: error: attribute requires precisely 1 argument
extern float bar __attribute__(( vector_size(16,18) ));
                                 ^
vector.c:11:34: error: vector_size requires integer constant (attribute ignored)
extern char foo2 __attribute__(( vector_size(16.2) ));
                                 ^           ~~~~
vector.c:21:47: error: invalid vector type 'struct s'
struct s { int a; } structVar __attribute__(( vector_size(16) ));

llvm-svn: 39643
2007-06-11 00:35:03 +00:00
Chris Lattner 3f4b6e3623 Fix lexing octal escapes like:
void foo() {
"\0";
}

llvm-svn: 39638
2007-06-09 06:20:47 +00:00
Chris Lattner ff591e24eb Don't warn about escaped newlines in // comments if the next line is also
a // comment, this reduces noise in the llvm testsuite.

llvm-svn: 39636
2007-06-09 06:07:22 +00:00
Chris Lattner de12ae2fd7 Add support for binary literals:
http://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html#Binary-constants

llvm-svn: 39621
2007-06-08 22:42:30 +00:00
Chris Lattner e8b2724017 Fix a bug steve noticed where we warned that __attribute is an extension,
but where we didn't warn about __attribute__.

llvm-svn: 39607
2007-06-08 17:27:55 +00:00
Chris Lattner 328fa5c913 Emit better diagnostics for out of range digits:
diag.c:1:9: error: invalid digit '8' in octal constant
int x = 000080;
        ^
diag.c:2:9: error: invalid digit 'A' in decimal constant
int z = 1000080ABC;
        ^

instead of:

diag.c:1:9: error: invalid suffix '80' on integer constant
int x = 000080;
        ^
diag.c:2:9: error: invalid suffix 'ABC' on integer constant
int z = 1000080ABC;
        ^

llvm-svn: 39605
2007-06-08 17:12:06 +00:00
Bill Wendling 44ebec5310 Submitted by: Bill Wendling
Removed #include <iostream>.

llvm-svn: 39554
2007-06-02 05:06:35 +00:00
Bill Wendling 5a85f9104d Bug #:
Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Removed unneeded <iostream> header.

llvm-svn: 39484
2007-05-23 08:05:58 +00:00
Chris Lattner 67ca9252f8 Implement Sema::ParseNumericConstant for integer constants in terms of APInt
and correctly in terms of C99 6.4.4.1p5.

llvm-svn: 39473
2007-05-21 01:08:44 +00:00
Chris Lattner 812eda8259 implement octal escape sequences.
llvm-svn: 39463
2007-05-20 05:17:04 +00:00
Chris Lattner c10adde406 Implement hex escape sequences in string and character literals, e.g. L"\x12345"
llvm-svn: 39462
2007-05-20 05:00:58 +00:00
Chris Lattner 36982e4367 Add support for inserting up to 10 strings in a diagnostic, with %0, %1, %2,
etc.

llvm-svn: 39447
2007-05-16 17:49:37 +00:00
Chris Lattner 739e739b81 Remove the clang::SourceBuffer class, switch to the llvm::MemoryBuffer class.
llvm-svn: 39426
2007-04-29 07:12:06 +00:00
Chris Lattner 89399da91a fixme done!
llvm-svn: 39407
2007-04-11 04:16:36 +00:00
Chris Lattner 99ca091b9c Warn when performing 'usual' conversions that require a sign change. This
implements test/Preprocessor/expr_usual_conversions.c, which produces this
output:

expr_usual_conversions.c:5:10: warning: left side of operator converted from negative value to unsigned: -42 to 18446744073709551574
#if (-42 + 0U) / -2
         ^
expr_usual_conversions.c:5:16: warning: right side of operator converted from negative value to unsigned: -2 to 18446744073709551614
#if (-42 + 0U) / -2
               ^

llvm-svn: 39406
2007-04-11 04:14:45 +00:00
Chris Lattner 8ec9355a48 Overflow detection for multiply and divide. Fix a bug handling 'usual
arithmetic conversions'.

llvm-svn: 39405
2007-04-11 04:04:29 +00:00
Chris Lattner 7e61ac5a3c Catch overflow of negate. This allows us to emit:
t.c:2:17: warning: integer overflow in preprocessor expression
#if -(INTMAX_MAX+1)
                ^
t.c:2:5: warning: integer overflow in preprocessor expression
#if -(INTMAX_MAX+1)
    ^

GCC has some seriously confused source locations in this case:
t.c:2:19: warning: integer overflow in preprocessor expression
t.c:2:20: warning: integer overflow in preprocessor expression

column 19/20 are off the end of the line.

llvm-svn: 39404
2007-04-11 03:42:36 +00:00
Chris Lattner 028c7decef Overflow detection for +/-
llvm-svn: 39403
2007-04-11 03:34:29 +00:00
Chris Lattner 9cc755d535 Evaluate result into an explicit destination. No functionality change.
llvm-svn: 39402
2007-04-10 07:07:11 +00:00
Chris Lattner 5a0f164a52 Track overflow of shift amounts, allowing diagnostics like:
t.c:6:7: warning: integer overflow in preprocessor expression
#if 1 << 63
      ^
t.c:8:7: warning: integer overflow in preprocessor expression
#if 4 << 62
      ^
t.c:10:7: warning: integer overflow in preprocessor expression
#if 4 << 66
      ^

but no diagnostic on:
#if 1U << 63

llvm-svn: 39400
2007-04-10 06:54:33 +00:00
Chris Lattner a7fa1b247c 'true' in a CPP expression evaluates to 1 when in C++ mode. This implements
test/Preprocessor/cxx_true.cpp

llvm-svn: 39399
2007-04-10 06:16:30 +00:00
Chris Lattner 7c718bd5a4 Include the filename being looked up in an error message. This gives us stuff
like this:
t3.c:5:10: error: 'vers2.h' file not found
#include xstr(INCFILE(2).h)
         ^

instead of:

t3.c:5:10: error: file not found
#include xstr(INCFILE(2).h)
         ^

which is useful if the #include name is generated through macro expansion.

llvm-svn: 39398
2007-04-10 06:02:46 +00:00
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