Chris Lattner
93ab9f134e
refactor the interface to Preprocessor::GetIncludeFilenameSpelling,
...
no functionality changes.
llvm-svn: 40414
2007-07-23 04:15:27 +00:00
Chris Lattner
32e6d64176
fix a bug getting the spelling of an identifier token
...
that required cleaning. If the token required cleaning,
don't include the cleaned tokens in the returned length.
llvm-svn: 40410
2007-07-22 22:50:09 +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
5c98379b1c
Correctly respect C99 5.1.1.2p4 when searching for the first '(' of
...
a function-like macro invocation. Patch contributed by Neil Booth.
llvm-svn: 40026
2007-07-19 00:07:36 +00:00
Chris Lattner
8a7003cd9f
Add a new Preprocessor::AdvanceToTokenCharacter method which, given a sloc
...
specifying the start of a token and a logical (phase 3) character number,
returns a sloc representing the input character corresponding to it.
llvm-svn: 39905
2007-07-16 06:48:38 +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
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
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
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
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
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
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
cf6bc66421
silence some warnings when asserts are disabled.
...
llvm-svn: 39127
2006-11-05 07:59:08 +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
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
bcb416bbd5
Implement test/Preprocessor/comment_save_if.c
...
llvm-svn: 39069
2006-10-27 05:43:50 +00:00
Chris Lattner
07b019a1bc
add #include
...
llvm-svn: 39034
2006-10-22 07:28:56 +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
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
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