Chris Lattner
c6ad8131dd
implement AST representation for function types with and without a prototype.
...
This lets us pretty print stuff like this:
void foo() {
int X;
X = sizeof(void (*(*)())());
X = sizeof(int(*)(int, float, ...));
X = sizeof(void (*(int arga, void (*argb)(double Y)))(void* Z));
as:
X = sizeof(void (*(*)())())
X = sizeof(int (*)(int, float, ...))
X = sizeof(void (*(int, void (*)(double)))(void *))
Ah the wonders of 'modern' C syntax!
llvm-svn: 39232
2006-12-02 07:52:18 +00:00
Chris Lattner
216d8654fd
implement ParseParamDeclaratorType in the ast builder
...
llvm-svn: 39231
2006-12-02 06:47:41 +00:00
Chris Lattner
cbc426d4f7
Next step of retaining information about function prototypes: actually retain
...
the info. Also, call Actions.ParseParamDeclaratorType instead of
Actions.ParseDeclarator for parameter type lists: we don't want declaration
objects created when parsing a function declarator, we just want type info.
llvm-svn: 39230
2006-12-02 06:43:02 +00:00
Chris Lattner
edc9e39d88
First step towards accurately retaining information about function
...
parameters: build an array of ParamInfo structures and pass it to the
declarator for safe keeping (it owns the list).
Next step: actually populate the arg array with useful stuff.
llvm-svn: 39229
2006-12-02 06:21:46 +00:00
Chris Lattner
b20e89449f
capture sourcelocation info for type specifiers. This improves diagnostics
...
for things like 'short _Complex'.
llvm-svn: 39227
2006-11-28 05:30:29 +00:00
Chris Lattner
60809f5aaf
record location info for const/volatile/restrict
...
llvm-svn: 39226
2006-11-28 05:18:46 +00:00
Chris Lattner
1b22eed03c
add loc info for the inline specifier, fix some fixme's by using it.
...
llvm-svn: 39225
2006-11-28 05:12:07 +00:00
Chris Lattner
4d8f873b5b
record accurate sourceloc info for storage class specs, so we can report
...
things like:
t.c:4:10: error: invalid storage class specifier in function declarator
int foo2(auto int Aaslfkasdflkj, register B);
^
instead of:
t.c:4:19: error: invalid storage class specifier in function declarator
int foo2(auto int Aaslfkasdflkj, register B);
^
llvm-svn: 39224
2006-11-28 05:05:08 +00:00
Chris Lattner
353f5740b1
Finish converting DeclSpec to use accessors.
...
llvm-svn: 39223
2006-11-28 04:50:12 +00:00
Chris Lattner
a925dc66e4
Convert more code to use DeclSpec accessors
...
llvm-svn: 39222
2006-11-28 04:33:46 +00:00
Chris Lattner
f055d43211
add accessors to DeclSpec, start moving clients over to use them.
...
llvm-svn: 39221
2006-11-28 04:28:12 +00:00
Chris Lattner
0d0111b8e4
Group declspec ivars together.
...
llvm-svn: 39220
2006-11-28 04:10:07 +00:00
Chris Lattner
43e956c3b7
verify C99 6.7.5.3p2
...
llvm-svn: 39219
2006-11-28 04:05: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
00348acace
clear file info after processing one file, it shouldn't carry over to the
...
next.
llvm-svn: 39211
2006-11-21 06:34:57 +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
a92809b1ab
add an accessor
...
llvm-svn: 39206
2006-11-21 05:52:33 +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
740b2f30c7
When a decl is popped from its current scope, link it to the decl chain for
...
the containing function. This avoids leaking decls.
llvm-svn: 39197
2006-11-21 01:32:20 +00:00
Chris Lattner
229ce60fc9
split the ParseFunctionDefinition action into two actions, one which is
...
called before and one which is called after function definition parsing.
llvm-svn: 39196
2006-11-21 01:21:07 +00:00
Chris Lattner
ac18be9ad2
Add support for C90 implicitly defined functions, e.g.:
...
int A() {
return X();
}
llvm-svn: 39194
2006-11-20 06:49:47 +00:00
Chris Lattner
5efbb33a6b
remember referenced decls in our AST's
...
llvm-svn: 39193
2006-11-20 05:01:40 +00:00
Chris Lattner
17ed487947
parse identifier expressions properly. This allows us diagnose this:
...
typedef int X;
int A() {
return X;
}
int B() {
return Y;
}
as:
/Users/sabre/test.c:5:10: error: unexpected type name 'X': expected expression
return X;
^
/Users/sabre/test.c:9:10: error: use of undeclared 'Y' value
return Y;
^
llvm-svn: 39192
2006-11-20 04:58:19 +00:00
Chris Lattner
0d8b1a1eff
remember and pretty-print cast types
...
llvm-svn: 39191
2006-11-20 04:34:45 +00:00
Chris Lattner
d0342e5989
Create a new TypeNameType class, which represents typedefs as types. This
...
allows us to handle stuff like:
typedef int G;
..
X = sizeof(G);
llvm-svn: 39189
2006-11-20 04:02:15 +00:00
Chris Lattner
2ebe4bb64d
when a typedef name is parsed as part of declspecs, remember the decl for the
...
typedef.
llvm-svn: 39188
2006-11-20 01:29:42 +00:00
Chris Lattner
5ca17df626
decls should all have types
...
llvm-svn: 39187
2006-11-19 23:32:49 +00:00
Chris Lattner
591a675b1c
remove #include of clang/Parse/DeclSpec.h from clang/AST/Decl.h
...
llvm-svn: 39186
2006-11-19 23:16:18 +00:00
Chris Lattner
da8aa7b3a8
implement RTTI for Decl objects, eliminate some hokey virtual methods.
...
llvm-svn: 39185
2006-11-19 23:12:30 +00:00
Chris Lattner
200bdc3b90
add an action method for declspecs without declarators, like "struct foo;".
...
llvm-svn: 39184
2006-11-19 02:43:37 +00:00
Chris Lattner
94c22cd5b9
rename ParsedClassDeclaration -> ParsedObjcClassDeclaration.
...
llvm-svn: 39183
2006-11-19 02:35:21 +00:00
Chris Lattner
302b4be4c2
build TypedefDecl objects when parsing typedefs.
...
Add a parsing fastpath for when we see typedef at the top-level.
llvm-svn: 39182
2006-11-19 02:31:38 +00:00
Chris Lattner
33e8a55ed0
Parse and remember types enough that we can pretty print:
...
void foo(int X) {
X = __alignof(int);
X = sizeof(const int** restrict ** volatile*);
}
as:
x = __alignof(int)
x = sizeof(int const **restrict **volatile *)
llvm-svn: 39181
2006-11-19 01:48:02 +00:00
Chris Lattner
558cb292da
add an action for parsing type names.
...
llvm-svn: 39180
2006-11-19 01:31:06 +00:00
Chris Lattner
9dfdb3c70d
rearrange the type printing code so that we can do the horrible C "inside out"
...
thing properly. This allows us to print types like:
int (*A)[restrict static 4][6];
properly, in addition to representing them properly. :)
llvm-svn: 39178
2006-11-13 07:38:09 +00:00
Chris Lattner
d235d162d0
change print methods to render into a string, which is more useful for diagnostics
...
and for handling precedence of types more accurately
llvm-svn: 39177
2006-11-13 06:22:30 +00:00
Chris Lattner
7ccecb90d4
Implement parsing, printing and AST'ing of array types (except for the bounds).
...
This allows us to handle:
int (*A)[restrict static 4][6];
for example.
llvm-svn: 39176
2006-11-12 08:50:50 +00:00
Chris Lattner
47814666e1
Implement and use isa/dyncast/cast etc for Type classes.
...
llvm-svn: 39175
2006-11-12 00:56:20 +00:00
Chris Lattner
d5973ebbe2
Teach ASTContext to delete all created types in its dtor.
...
Teach getPointerType to (stupidly) memoize all created pointers.
Give types an enum so we can implement classof.
llvm-svn: 39174
2006-11-12 00:53:46 +00:00
Chris Lattner
970e54e3ac
Build ASTs for the pointer qualifiers on declarators. This allows us to
...
parse (and print) things like:
int* const* restrict* const volatile***
etc.
llvm-svn: 39173
2006-11-12 00:37:36 +00:00
Chris Lattner
aecbefa519
We can now parse and remember the distinction between:
...
'unsigned char' and 'unsigned char const'.
-Chris
llvm-svn: 39172
2006-11-12 00:05:06 +00:00
Chris Lattner
8ddf65053e
DeclSpec::TQ and TypeRef::TQ should stay in sync
...
llvm-svn: 39171
2006-11-11 23:59:23 +00:00
Chris Lattner
5983de06cd
add note about eliminating DeclSpec.
...
Add TypeRef::dump method.
llvm-svn: 39169
2006-11-11 23:56:01 +00:00
Chris Lattner
96bff30868
fix comment
...
llvm-svn: 39168
2006-11-11 23:55:28 +00:00
Chris Lattner
288e86ff15
Rename SemaDeclSpec.{h|cpp} back to DeclSpec.{h|cpp} now that the distinction
...
between sema and parse is clear.
llvm-svn: 39167
2006-11-11 23:03:42 +00:00
Chris Lattner
f84a79c4e9
restructure code to build the framework for creating types from declarators.
...
llvm-svn: 39166
2006-11-11 22:59:23 +00:00
Chris Lattner
f391a3ba70
Expand TypeRef itf
...
llvm-svn: 39165
2006-11-10 07:21:44 +00:00
Chris Lattner
ef51c20065
add the builtin types
...
llvm-svn: 39164
2006-11-10 07:17:23 +00:00
Chris Lattner
3522b20265
Tweak Type.h to compile.
...
llvm-svn: 39163
2006-11-10 06:49:39 +00:00
Chris Lattner
ddc135e593
Let ASTContext hold target info, since it's useful
...
llvm-svn: 39162
2006-11-10 06:34:16 +00:00
Chris Lattner
cb6a382b67
introduce a new ASTContext class to hold long-lived ast nodes.
...
llvm-svn: 39161
2006-11-10 06:20:45 +00:00
Chris Lattner
bd638926e2
remove diag helper that implicitly reports the diagnostic at the current
...
token: it is better for the code to be explicit.
llvm-svn: 39158
2006-11-10 05:19:25 +00:00
Chris Lattner
eaafe122b6
move semantic analysis of break/continue out of the parser into the sema class.
...
llvm-svn: 39157
2006-11-10 05:17:58 +00:00
Chris Lattner
697e5d692b
Change courses on how we do semantic analysis. Semantic analysis
...
fundamentally requires having an AST around, so move all sema to the
AST library. This is the first step, later steps will be needed to
clean up libast.
llvm-svn: 39150
2006-11-09 06:32:27 +00:00
Chris Lattner
289ab7bb1d
rename SemaDecl.cpp/h to SemaDeclSpec.cpp/h
...
llvm-svn: 39149
2006-11-08 06:54:53 +00:00
Chris Lattner
b26b665742
rename these methods so that they read correctly.
...
llvm-svn: 39148
2006-11-08 06:10:32 +00:00
Chris Lattner
3503cefbba
split ParseStringExpr into semantic/minimal actions
...
llvm-svn: 39147
2006-11-08 06:03:59 +00:00
Chris Lattner
257aae5b47
add a note
...
llvm-svn: 39145
2006-11-08 06:03:16 +00:00
Chris Lattner
e030db6901
Structure for the type representation.
...
llvm-svn: 39143
2006-11-08 05:45:01 +00:00
Chris Lattner
f89b50c38d
init std::string with it's default ctor instead of "".
...
llvm-svn: 39141
2006-11-06 06:37:47 +00:00
Chris Lattner
034a18c3d2
use default ctor
...
llvm-svn: 39140
2006-11-06 06:33:29 +00:00
Chris Lattner
168f349036
this is not a converting ctor
...
llvm-svn: 39139
2006-11-06 06:31:59 +00:00
Chris Lattner
b6a0e1781f
implement trivial scope caching. This reduces malloc traffic in the common
...
case, speeding up parsing of this contrived example:
#define A {{}}
#define B A A A A A A A A A A
#define C B B B B B B B B B B
#define D C C C C C C C C C C
#define E D D D D D D D D D D
#define F E E E E E E E E E E
#define G F F F F F F F F F F
#define H G G G G G G G G G G
void foo() {
H
}
from 7.478s to 4.321s. GCC requires 8.2s.
llvm-svn: 39138
2006-11-06 00:22:42 +00:00
Chris Lattner
1576870356
pretty print postfix ++/-- nicer
...
llvm-svn: 39137
2006-11-05 23:54:51 +00:00
Chris Lattner
33ad2cacc9
Make Scope keep track of the kind of scope it is. Properly scope loop and
...
switch statements. Make break/continue check that they are inside of an
appropriate control-flow construct. This implements Parser/bad-control.c.
llvm-svn: 39136
2006-11-05 23:47:55 +00:00
Chris Lattner
c62b6c232f
eliminate EmptyAction, merging it into MinimalAction instead.
...
llvm-svn: 39134
2006-11-05 18:44:26 +00:00
Chris Lattner
0663d2afd9
start factoring actions into two flavors: minimal and semantic actions.
...
llvm-svn: 39133
2006-11-05 18:39:59 +00:00
Chris Lattner
7ad0fbe1f2
rename a bunch of files for better consistency
...
llvm-svn: 39126
2006-11-05 07:46:30 +00:00
Chris Lattner
16976d3e83
build ast nodes and print goto/goto*/break/continue.
...
llvm-svn: 39121
2006-11-05 01:46:01 +00:00
Chris Lattner
6c0ff13761
Add ast node support for case/default/label stmts.
...
llvm-svn: 39120
2006-11-05 00:19:50 +00:00
Chris Lattner
f2174b633b
implement AST node for switch stmt
...
llvm-svn: 39119
2006-11-04 20:59:27 +00:00
Chris Lattner
76af84462c
use the StmtNodes.def database to eliminate redundant code.
...
llvm-svn: 39118
2006-11-04 20:54:18 +00:00
Chris Lattner
6fef2fb277
Add a new StmtNodes.def file as a catalog of all the Stmt's. This helps
...
eliminate repetitive code.
llvm-svn: 39117
2006-11-04 20:49:30 +00:00
Chris Lattner
85ed873bdc
implement ast nodes for while and do loops
...
llvm-svn: 39116
2006-11-04 20:40:44 +00:00
Chris Lattner
71e23ce2e1
Add AST node, AST building, actions, and printing for 'for' stmts.
...
llvm-svn: 39113
2006-11-04 20:18:38 +00:00
Chris Lattner
9277aeb5c1
add accessors to ast nodes, remove VisitNull method from the visitor which is dead
...
llvm-svn: 39110
2006-11-04 18:51:16 +00:00
Chris Lattner
9ea960a220
make visit methods take a reference to a visitor instead of a pointer.
...
Remove all dump_impl methods from Stmt subclasses
llvm-svn: 39108
2006-11-04 07:16:04 +00:00
Chris Lattner
72b7d39d78
remove full locinfo AST nodes for now. They just clutter the implementation
...
and should be implemented with an ASTBuilder subclass anyway.
llvm-svn: 39107
2006-11-04 06:37:16 +00:00
Chris Lattner
469d357425
implement visitor chaining.
...
llvm-svn: 39105
2006-11-04 06:32:52 +00:00
Chris Lattner
5e9a878126
add a new StmtVisitor class for traversing Stmt/Expr nodes.
...
llvm-svn: 39104
2006-11-04 06:21:51 +00:00
Chris Lattner
18d65c9b86
add a diagnostic
...
llvm-svn: 39098
2006-11-03 07:19:43 +00:00
Chris Lattner
8fb548fefd
fit in 80 cols, rename some methods.
...
llvm-svn: 39097
2006-11-03 07:19:18 +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
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
2f4a89a5e8
Switch the FileManager::FileEntries map over to using a CStringMap. This
...
speeds up preprocessing Cocoa.h 16% (from 0.99 to 0.85s).
llvm-svn: 39085
2006-10-30 03:55:17 +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
a85cbe28a0
Avoid storing a directory name in both the DirEntries map keys and in the
...
UniqueDirs value. Instead, just have the UniqueDirs value contain a pointer
to the key in the DirEntries map.
llvm-svn: 39083
2006-10-30 03:11:40 +00:00
Chris Lattner
af65375944
Switch DirEntries over to using a CStringMap. This speeds it up
...
'clang -Eonly INPUTS/Cocoa_h.m' by about 4%.
llvm-svn: 39082
2006-10-30 03:06:54 +00:00
Chris Lattner
8b1e848a04
Avoid some mallocs, and avoid leaking some memory, by making the
...
UniqueDirs/UniqueFiles maps own the memory for the FileEntry and DirEntries.
llvm-svn: 39081
2006-10-30 02:45:16 +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
cf163aa407
no need for these classes to be so friendly anymore.
...
llvm-svn: 39077
2006-10-29 21:37:52 +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
Steve Naroff
b419d3a80e
- Added basic structure for parsing top level Objective-C forms.
...
- Extended the typedef mechanism for classes, improved performance of the common case.
- Implemented @class in the parser.
llvm-svn: 39074
2006-10-27 23:18:49 +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
1eb290b2e9
remove namelen field, it is now dead
...
llvm-svn: 39064
2006-10-27 05:07:16 +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
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
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
ece49761a3
update comment
...
llvm-svn: 39052
2006-10-25 05:55:51 +00:00
Chris Lattner
5f84a0648d
add ast node for ifstmt
...
llvm-svn: 39051
2006-10-25 05:55:20 +00:00
Chris Lattner
c52b118676
Handle __extension__ as a unary operator if requested.
...
llvm-svn: 39050
2006-10-25 05:45:55 +00:00
Chris Lattner
6d9a685d75
Make the driver print function bodies at -parse-print-ast
...
llvm-svn: 39048
2006-10-25 05:11:20 +00:00
Chris Lattner
e5cca06829
Make AST nodes for ReturnStmt's and CompoundStmts
...
llvm-svn: 39046
2006-10-25 04:29:46 +00:00
Chris Lattner
f42cce7a8e
Add new Stmt class
...
llvm-svn: 39045
2006-10-25 04:09:21 +00:00
Chris Lattner
ae31969ad2
Finish removing LexerToken from actions interface
...
llvm-svn: 39044
2006-10-25 03:49:28 +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
5c3ac11bf5
Reduce amount #included
...
llvm-svn: 39035
2006-10-22 07:29:01 +00:00
Chris Lattner
25246dfeb0
Split the DirectoryLookup class out to its own header.
...
llvm-svn: 39033
2006-10-22 07:26:52 +00:00
Chris Lattner
5ed76da296
Implement framework filesystem caching.
...
llvm-svn: 39031
2006-10-22 07:24:13 +00:00
Chris Lattner
762d21b254
increase number of file ID's so we can preprocess carbon.h
...
llvm-svn: 39029
2006-10-22 06:34:00 +00:00
Chris Lattner
0b9bdd9a74
Use read to open small files so we don't run out of file descriptors as easily.
...
llvm-svn: 39027
2006-10-20 06:53:51 +00:00
Chris Lattner
641a0be31b
count # framework lookups
...
llvm-svn: 39026
2006-10-20 06:23:14 +00:00
Chris Lattner
7949310b49
Enable these keywords as extensions in c90
...
llvm-svn: 39025
2006-10-20 06:13:36 +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
04d1f3f75f
track whether DirectoryLookup dirs are framework dirs.
...
llvm-svn: 39006
2006-10-17 06:20:32 +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
04132371bb
Make ConsumeFoo methods return the location of the consumed token.
...
llvm-svn: 38995
2006-10-16 06:12:55 +00:00
Chris Lattner
af63531ac3
Make ConsumeToken return the loc of the consumed token to simplify clients
...
llvm-svn: 38994
2006-10-16 06:06:51 +00:00
Chris Lattner
30f910e88e
implement action callbacks for almost all the stmts.
...
llvm-svn: 38993
2006-10-16 05:52:41 +00:00
Chris Lattner
2dacc3ff2e
Changes through out the parser and actions/ast interface to return top-level
...
declarations through the asm streamer. For a testcase like:
int G;
int H, I, *J;
int func() {}
'clang -parse-print-ast' prints:
Read top-level decl: G
Read top-level decl: H
Read top-level decl: I
Read top-level decl: J
Read top-level decl: func
llvm-svn: 38992
2006-10-16 00:33:54 +00:00
Chris Lattner
a11999d83a
start creating proper ast nodes for variables and functions
...
llvm-svn: 38991
2006-10-15 22:34:45 +00:00
Chris Lattner
14a1b64418
create an ast node for &&label
...
llvm-svn: 38989
2006-10-15 22:33:58 +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
2194ddc83d
Add new TargetInfo hooks for getting the set of target-specific #defines.
...
llvm-svn: 38979
2006-10-14 18:32:26 +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
bc525438f7
Mark stuff const.
...
llvm-svn: 38974
2006-10-14 07:39:48 +00:00
Chris Lattner
1e27fe165c
Add new TargetInfo class to clang.
...
llvm-svn: 38971
2006-10-14 07:06:20 +00:00
Chris Lattner
509d3c00ed
Rename LexerToken methods to be more consistent
...
llvm-svn: 38970
2006-10-14 05:19:39 +00:00
Chris Lattner
6f433fd2d3
add accessor
...
llvm-svn: 38962
2006-10-06 05:40:22 +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
26da7302ce
Build AST's for sizeof/alignof with type operands.
...
llvm-svn: 38951
2006-08-24 06:49:19 +00:00
Chris Lattner
e550a4ea12
Build CastExpr AST nodes
...
llvm-svn: 38950
2006-08-24 06:37:51 +00:00
Chris Lattner
26115acb1c
Build AST's for sizeof/alignof an expr.
...
llvm-svn: 38949
2006-08-24 06:10:04 +00:00
Chris Lattner
6f3a117f81
switch MemberExpr to holding a field decl instead of a raw identifier.
...
llvm-svn: 38948
2006-08-24 05:19:28 +00:00
Chris Lattner
98286a4551
Allow expression actions to fail
...
llvm-svn: 38947
2006-08-24 05:02:11 +00:00
Chris Lattner
e1598f0184
Move the ExprResult struct from the Parser to the Actions.
...
llvm-svn: 38946
2006-08-24 04:56:36 +00:00
Chris Lattner
879b9ad083
Add initial support for simple-primary exprs, including DeclExprs.
...
llvm-svn: 38944
2006-08-24 04:53:44 +00:00
Chris Lattner
e165d944c2
Add AST nodes for array, call, . and ->.
...
llvm-svn: 38943
2006-08-24 04:40:38 +00:00
Chris Lattner
de648186eb
Add actions for postfix exprs
...
llvm-svn: 38941
2006-08-24 03:51:14 +00:00
Chris Lattner
1b92649857
Add AST nodes and actions for paren exprs and simple unary ops.
...
llvm-svn: 38940
2006-08-23 06:42:10 +00:00
Chris Lattner
9b6d4cb90e
Add (basic) expression AST representation capabilities for int/fp/binops/condexpr.
...
Add callbacks for same.
Add "full locinfo" mode.
llvm-svn: 38939
2006-08-23 05:17:46 +00:00
Chris Lattner
c11438cee1
Implement first cut of ASTBuilder class.
...
llvm-svn: 38938
2006-08-18 05:17:52 +00:00
Chris Lattner
38ba3363ef
Hook up more of the ASTStreamer
...
llvm-svn: 38936
2006-08-17 07:04:37 +00:00
Chris Lattner
73709eda2b
Stub out the ASTStreamer
...
llvm-svn: 38935
2006-08-17 06:28:25 +00:00
Chris Lattner
3e7bd4ed44
Start adding support for printing out parser callbacks and adding ast building
...
llvm-svn: 38933
2006-08-17 05:51:27 +00:00
Chris Lattner
d0745a08b6
New file
...
llvm-svn: 38931
2006-08-17 05:18:35 +00:00
Chris Lattner
3242dfdd55
move to AST
...
llvm-svn: 38930
2006-08-17 05:18:27 +00:00
Chris Lattner
0116c478e6
Implement asm statement parsing.
...
llvm-svn: 38929
2006-08-15 06:03:28 +00:00
Chris Lattner
04f8019616
Make MatchRHSPunctuation smarter, allowing its clients to be simpler.
...
llvm-svn: 38926
2006-08-15 04:55:54 +00:00
Chris Lattner
b8cd5c2260
Parse (and ignore) attributes on global decls.
...
llvm-svn: 38924
2006-08-15 04:10:46 +00:00
Chris Lattner
6d7e634399
Parse asm specifiers on init declarators. Add __builtin_va_list to the
...
symbol table at startup time.
llvm-svn: 38922
2006-08-15 03:41:14 +00:00
Chris Lattner
68ca25f8a9
Add accessor for the DeclSpec object.
...
llvm-svn: 38918
2006-08-14 00:57:25 +00:00
Chris Lattner
9a9d7ec822
Add accessors for scope info.
...
llvm-svn: 38917
2006-08-14 00:57:12 +00:00
Chris Lattner
bd78161d95
Add DeclTy typedef.
...
llvm-svn: 38916
2006-08-14 00:57:06 +00:00
Chris Lattner
3b4fdda3d8
Fix the last remaining FIXME's in the parser by asking the actions module
...
whether or not an identifier is a typedef name.
llvm-svn: 38915
2006-08-14 00:45:39 +00:00
Chris Lattner
a5534f96dc
Stub out the EmptyAction class.
...
llvm-svn: 38914
2006-08-14 00:38:06 +00:00
Chris Lattner
685ed1e9ee
Rename Parse/ParserActions.h -> Parse/Action.h
...
llvm-svn: 38913
2006-08-14 00:22:04 +00:00
Chris Lattner
e4e38595b0
Add methods for scope manipulation.
...
llvm-svn: 38909
2006-08-14 00:15:05 +00:00
Chris Lattner
78b917603c
Add some methods, add significant documentation.
...
llvm-svn: 38908
2006-08-14 00:14:19 +00:00
Chris Lattner
8c88b5a981
add accessor method for parent.
...
llvm-svn: 38907
2006-08-14 00:13:44 +00:00
Chris Lattner
da72c82e8e
Recognize struct/union/enum as TypeSpecType's
...
llvm-svn: 38903
2006-08-13 22:16:42 +00:00
Chris Lattner
476c3adb69
implement the GNU case-range extension. Add todo's for other missing gnu extensions.
...
llvm-svn: 38902
2006-08-13 22:09:58 +00:00
Chris Lattner
8693a519d4
Implement initializer parsering.
...
llvm-svn: 38900
2006-08-13 21:54:02 +00:00
Chris Lattner
1890ac8b03
Parse struct/union specifiers.
...
llvm-svn: 38897
2006-08-13 01:16:23 +00:00
Chris Lattner
3b561a3b39
Implement parsing of enum-specifiers.
...
llvm-svn: 38896
2006-08-13 00:12:11 +00:00
Chris Lattner
dbb2a46915
Add a new ExpectAndConsume method to make parsing easier, and add a new
...
ConsumeAnyToken method.
llvm-svn: 38894
2006-08-12 19:26:13 +00:00
Chris Lattner
1112435558
Parse the GNU builtin expressions. This implements Parser/expressions.c:test_offsetof
...
llvm-svn: 38893
2006-08-12 19:16:08 +00:00
Chris Lattner
6259172911
Implement parsing of array declarators like:
...
int Array[*(int*)P+A];
llvm-svn: 38890
2006-08-12 18:40:58 +00:00
Chris Lattner
0c6c034c48
Two fixes:
...
1. Allow argument list of a call to be empty.
2. Handle expressions in a statement context that start with an identifier.
These are nasty to handle due to the 'label:' production which requires
having two tokens of look-ahead, or by having tricky code (which we
choose to do).
llvm-svn: 38887
2006-08-12 18:12:45 +00:00
Chris Lattner
20c6a45a3c
Split postfix-expression suffix handling out into ParsePostfixExpressionSuffix
...
for future use.
llvm-svn: 38885
2006-08-12 17:40:43 +00:00
Chris Lattner
d35c34f44d
Fix incorrect parsing of the ?: middle term, which is supposed to be
...
parsed as 'expression'. This implements test/Parser/statements.c
llvm-svn: 38879
2006-08-12 17:04:50 +00:00
Chris Lattner
6c3f05d1d2
Diagnose use of compound literals in C90 code
...
llvm-svn: 38876
2006-08-12 16:54:25 +00:00
Chris Lattner
cde626ae9b
Implement a first cut at binary expression parsing using a simple operator
...
precedence-based parser.
llvm-svn: 38874
2006-08-12 08:13:25 +00:00
Chris Lattner
89c50c65af
Return information about whether expression parsing was successful
...
llvm-svn: 38873
2006-08-11 06:41:18 +00:00
Chris Lattner
81b576ee0d
Merge ParsePostfixExpression into ParseCastExpression. This allows us to
...
implement support for compound literals followed by postfix-expr suffixes,
such as:
(struct{ int a;}){ 1}.a
llvm-svn: 38871
2006-08-11 02:13:20 +00:00
Chris Lattner
eaf06598ea
Merge ParseUnaryExpression and ParseCastExpression.
...
llvm-svn: 38869
2006-08-11 02:02:23 +00:00
Chris Lattner
4add4e6c12
Simplify paren parsing, finish parsing of sizeof expressions and other cases.
...
llvm-svn: 38866
2006-08-11 01:33:00 +00:00
Chris Lattner
f5fbd7963d
Implement type-name parsing, and simple compound initializer parsing.
...
llvm-svn: 38865
2006-08-10 23:56:11 +00:00
Chris Lattner
4564bc1123
Factor some code into the new Parser::MatchRHSPunctuation method.
...
llvm-svn: 38864
2006-08-10 23:14:52 +00:00
Chris Lattner
c2dd85ac9e
Implement most of unary-expression parsing.
...
llvm-svn: 38862
2006-08-10 22:57:16 +00:00
Chris Lattner
f833977a8a
implement postfix-expression parsing.
...
llvm-svn: 38861
2006-08-10 22:01:51 +00:00
Chris Lattner
52a99e5cee
Parse primary expressions, handle string concatenation
...
llvm-svn: 38860
2006-08-10 20:56:00 +00:00
Chris Lattner
c5e0d4a6ae
stub out some entry points for the expr parsing code.
...
llvm-svn: 38858
2006-08-10 19:06:03 +00:00
Chris Lattner
f8afb62ef9
Add support for parsing declarations in blocks. This implements
...
Parser/statements.c:test4
llvm-svn: 38852
2006-08-10 18:26:31 +00:00
Chris Lattner
d2685cf6bb
Parse case/default labeled-statements.
...
llvm-svn: 38851
2006-08-10 05:59:48 +00:00
Chris Lattner
503fadc90f
Parse jump-statement: goto, continue, break, return.
...
llvm-svn: 38849
2006-08-10 05:45:44 +00:00
Chris Lattner
ab180365ac
Add a warning
...
llvm-svn: 38848
2006-08-10 05:22:36 +00:00
Chris Lattner
53361ac130
Refactor init-declarator-list parsing code to allow for-statements to have
...
initializers in them.
llvm-svn: 38847
2006-08-10 05:19:57 +00:00
Chris Lattner
9075bd7727
implement switch/while/do/for statement parsing, implementing Parser/statements.c:test2
...
llvm-svn: 38846
2006-08-10 04:59:57 +00:00
Chris Lattner
c951dae2a4
Parse if statements
...
llvm-svn: 38844
2006-08-10 04:23:57 +00:00
Chris Lattner
0ccd51ebe2
Start parsing statements and function bodies. This implements
...
Parser/statements.c:test1.
llvm-svn: 38842
2006-08-09 05:47:47 +00:00
Chris Lattner
fff824fe14
Simplify and fill out parsing of function bodies.
...
llvm-svn: 38841
2006-08-07 06:31:38 +00:00
Chris Lattner
2534b877b4
add some accessor methods.
...
llvm-svn: 38840
2006-08-07 05:50:47 +00:00
Chris Lattner
bf320c84a5
better comments, infrastructure for parsing function bodies.
...
llvm-svn: 38839
2006-08-07 05:05:30 +00:00
Chris Lattner
d5d0a6c2b5
Capture function information, provide a place to validate Declarator information.
...
llvm-svn: 38838
2006-08-07 00:58:14 +00:00
Chris Lattner
6c7416c382
Start capturing pointer and array declarator info.
...
llvm-svn: 38836
2006-08-07 00:19:33 +00:00
Chris Lattner
14776b9501
Implement some more error recovery
...
llvm-svn: 38835
2006-08-06 22:27:40 +00:00
Chris Lattner
0ef405cdb9
MAke the default be to stop at ;'s
...
llvm-svn: 38834
2006-08-06 22:00:57 +00:00
Chris Lattner
eec40f9990
Start implementing error recovery, this implements test/Parser/recovery-1.c
...
llvm-svn: 38833
2006-08-06 21:55:29 +00:00
Chris Lattner
8a39edc931
Warn for c99-specific array use
...
llvm-svn: 38830
2006-08-06 18:33:32 +00:00
Chris Lattner
e8074e65dd
Parse array declarators, tested by Parser/declarators.c
...
llvm-svn: 38828
2006-08-06 18:30:15 +00:00
Chris Lattner
acd58a3c33
Parse parenthesized and function declarators now, allowing us to parse things
...
like: "void (*signal(int, void (*)(int)))(int);"
llvm-svn: 38824
2006-08-06 17:24:14 +00:00
Chris Lattner
15356a7065
Start capturing declarator information in a new Declarator object.
...
llvm-svn: 38823
2006-08-06 00:02:28 +00:00
Chris Lattner
2df305abfa
New file
...
llvm-svn: 38822
2006-08-05 23:08:14 +00:00
Chris Lattner
971c6b681a
Add scaffolding for scopes.
...
llvm-svn: 38821
2006-08-05 22:46:42 +00:00
Chris Lattner
2d4f2c3ebe
Update comment
...
llvm-svn: 38820
2006-08-05 22:09:17 +00:00
Chris Lattner
d9c3c59fc0
Continue work on declspecs and declarations
...
llvm-svn: 38818
2006-08-05 06:26:47 +00:00
Chris Lattner
f63f89acc2
Handle __thread and storage-class-specifiers
...
llvm-svn: 38816
2006-08-05 03:28:50 +00:00
Chris Lattner
fe533e3ecd
make error message more useful
...
llvm-svn: 38815
2006-08-05 02:54:06 +00:00
Chris Lattner
1ae23294fb
C99 requires at least one type specifier.
...
llvm-svn: 38813
2006-08-04 06:42:31 +00:00
Chris Lattner
fef9d2bba7
Diagnose specifiers with invalid _Complex/_Imaginary components.
...
llvm-svn: 38812
2006-08-04 06:36:52 +00:00
Chris Lattner
839713c085
Emit diagnostics for things like 'signed _Bool' and 'short float'
...
llvm-svn: 38811
2006-08-04 06:15:52 +00:00
Chris Lattner
494f27a0b8
Enable _Bool as an extension in C++
...
llvm-svn: 38810
2006-08-04 06:12:13 +00:00
Chris Lattner
da48a8e66b
Parse and validate cvr type-qualifiers
...
llvm-svn: 38807
2006-08-04 05:25:55 +00:00
Chris Lattner
22dc378630
Split LangOptions out into its own header
...
llvm-svn: 38806
2006-08-04 04:44:06 +00:00
Chris Lattner
b9093cd1d0
Add an initial cut at a datastructure for holding declspec's.
...
llvm-svn: 38805
2006-08-04 04:39:53 +00:00
Chris Lattner
70f32b7d68
Add initial very-incomplete support for parsing declarations. We just manage
...
to be able to parse "int x;" now.
llvm-svn: 38803
2006-07-31 05:09:04 +00:00
Chris Lattner
0bb5f835e4
initial support for parsing, right now just ;'s at the top level, but this
...
adds most simple scaffolding.
llvm-svn: 38802
2006-07-31 01:59:18 +00:00
Chris Lattner
34dfaee634
Misc cleanups
...
llvm-svn: 38801
2006-07-31 01:57:54 +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
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
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
6d9f8ed3b6
No need for explicit underscore anymore.
...
llvm-svn: 38773
2006-07-29 03:52:06 +00:00
Chris Lattner
f9771166ed
add method to unpoison something for __VA_ARGS__.
...
llvm-svn: 38772
2006-07-29 03:47:18 +00:00
Chris Lattner
3ce273025e
Remove __VA_ARGS__ "keyword".
...
llvm-svn: 38771
2006-07-29 03:47:08 +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
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
7fa8c889e2
Add a single-entry cache for macro instantation locations. This significantly
...
reduces the number of FileID's made and tracked.
llvm-svn: 38752
2006-07-20 06:48:52 +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
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
22549fe6a5
With recent simplifications, this check can be removed from a fastpath.
...
llvm-svn: 38745
2006-07-20 04:20:02 +00:00
Chris Lattner
4505e89d0f
Make diagnostic message better
...
llvm-svn: 38740
2006-07-19 06:41:46 +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
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
e1954ac1a3
Fix comment
...
llvm-svn: 38721
2006-07-15 23:40:13 +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
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
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
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
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
370c135dce
improve comment
...
llvm-svn: 38696
2006-07-11 04:03:32 +00:00
Chris Lattner
2acdac4200
Implement scanning-for-( more correctly. This implements
...
test/Preprocessor/macro_fn_lparen_scan.c, but is not yet complete.
llvm-svn: 38695
2006-07-11 04:02:48 +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
8eede3e6c0
Remove pointless comments.
...
llvm-svn: 38684
2006-07-08 23:24:05 +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
ae41157ee5
Implement support for arbitrarily mapping non-error diagnostics to be either
...
ignored, warned about, or error'd. Use this to implement the -Wunused_macros
command line option.
llvm-svn: 38676
2006-07-05 00:55:08 +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
5f084fd5fc
Add newline at end of file
...
llvm-svn: 38657
2006-07-04 19:03:36 +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
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
Chris Lattner
3665f161ca
Implement the multiple-include file optimization.
...
llvm-svn: 38647
2006-07-04 07:26:10 +00:00
Chris Lattner
371ac8a9b7
Implement the automaton for recognizing files with controlling macros.
...
llvm-svn: 38646
2006-07-04 07:11:10 +00:00
Chris Lattner
01d66cc891
Implement #ident and #sccs
...
llvm-svn: 38643
2006-07-03 22:16:27 +00:00
Chris Lattner
d7de629c32
Move a method inline
...
llvm-svn: 38639
2006-07-03 06:05:41 +00:00
Chris Lattner
bd07659488
Move a PragmaNamespace method out of line, add class comment for PragmaNamespace.
...
llvm-svn: 38637
2006-07-03 05:34:49 +00:00
Chris Lattner
13044d942d
Implement -Wunused-macros functionality.
...
llvm-svn: 38632
2006-07-03 05:16:44 +00:00
Chris Lattner
4ec473f871
Add support to track the real top-level file.
...
llvm-svn: 38630
2006-07-03 05:16:05 +00:00
Chris Lattner
91cbf11c10
Add a new IdentifierVisitor class and a new IdentifierTable::VisitIdentifiers
...
method to support iteration over all identifiers.
llvm-svn: 38628
2006-07-03 04:28:52 +00:00
Chris Lattner
44f8a66bcc
Fix test/Preprocessor/macro_defined.c, factor some code.
...
llvm-svn: 38627
2006-07-03 01:27:27 +00:00
Chris Lattner
aaf09115c4
Implement a FIXME: reject '#define defined'.
...
llvm-svn: 38625
2006-07-03 01:17:59 +00:00
Chris Lattner
e3e81ea8aa
Refactor some code into a new Lexer::Stringify method.
...
llvm-svn: 38624
2006-07-03 01:13:26 +00:00
Chris Lattner
a37664b3fb
Move a virtual method out-of-line
...
llvm-svn: 38617
2006-07-02 22:45:51 +00:00
Chris Lattner
1840e491dc
Remove Lexer::BufferStart, an unneeded instance var.
...
llvm-svn: 38615
2006-07-02 22:30:01 +00:00
Chris Lattner
ecfeafe3ba
Fix some minor bugs handling _Pragma, including
...
test/Preprocessor/_Pragma_syshdr.c
llvm-svn: 38609
2006-07-02 21:26:45 +00:00
Chris Lattner
ef0dbae5ab
remove dead ivar
...
llvm-svn: 38607
2006-07-02 21:17:13 +00:00
Chris Lattner
69772b026e
Implement the _Pragma-style of pragma handling, implementing
...
test/Preprocessor/_Pragma-poison.c.
This unifies the MacroStack and IncludeStack together into IncludeMacroStack.
llvm-svn: 38606
2006-07-02 20:34:39 +00:00
Chris Lattner
4cca5ba7da
Allow the buffer start/end positions to be optionally specified. Make sure
...
to use them instead of the current buffer start/end when computing diagnostics.
llvm-svn: 38603
2006-07-02 20:05:54 +00:00
Chris Lattner
847e0e4552
Implement __TIMESTAMP__
...
llvm-svn: 38602
2006-07-01 23:49:16 +00:00
Chris Lattner
c1283b90a0
Implement __INCLUDE_LEVEL__ and __BASE_FILE__
...
llvm-svn: 38601
2006-07-01 23:16:30 +00:00
Chris Lattner
630b33c39e
Implement __FILE__
...
llvm-svn: 38600
2006-07-01 22:46:53 +00:00
Chris Lattner
4c37a8c353
Eliminate SourceManager::createFileIDForMacroExp, inlining it into its single use.
...
llvm-svn: 38599
2006-06-30 06:15:08 +00:00
Chris Lattner
c673f905d8
Implement the __TIME__ and __DATE__ builtin macros.
...
llvm-svn: 38597
2006-06-30 06:10:41 +00:00
Chris Lattner
7d6a4f6746
Expose a useful helper method.
...
llvm-svn: 38596
2006-06-30 06:10:08 +00:00
Chris Lattner
098dfc5e7e
Expose a new form of the getToken method.
...
llvm-svn: 38595
2006-06-30 06:09:36 +00:00
Chris Lattner
2dffd2b445
Factor logical line lookup better.
...
llvm-svn: 38594
2006-06-29 16:44:08 +00:00
Chris Lattner
0b8cfc2e69
Implement the __LINE__ builtin macro.
...
llvm-svn: 38589
2006-06-28 06:49:17 +00:00
Chris Lattner
3690f1513a
Initial implementation of the ScratchBuffer class.
...
llvm-svn: 38588
2006-06-28 06:48:36 +00:00
Chris Lattner
ec43eaf07a
Add a new SourceBuffer::getNewMemBuffer method.
...
llvm-svn: 38587
2006-06-28 06:35:31 +00:00
Chris Lattner
677757a2c0
Remove dead variables.
...
Add initial support for builtin macros, including warning if they are defined or undefined.
Register __LINE__ as a builtin macro.
llvm-svn: 38586
2006-06-28 05:26:32 +00:00
Chris Lattner
274690ce76
Reindent comments.
...
llvm-svn: 38585
2006-06-28 05:25:35 +00:00
Chris Lattner
f373a4af56
Refactor HandleIdentifier to pull macro expansion into its own method.
...
llvm-svn: 38583
2006-06-26 06:16:29 +00:00
Chris Lattner
e9a5e18e47
remove some obsolete comments
...
llvm-svn: 38582
2006-06-26 06:08:38 +00:00
Chris Lattner
67b07cb6fe
Implement Preprocessor/macro_expandloc.c by giving the optimized macro
...
expansion case a correct source location.
llvm-svn: 38580
2006-06-26 02:03:42 +00:00
Chris Lattner
f6fd68add5
Fix Preprocessor/macro_expandloc2.c
...
llvm-svn: 38579
2006-06-26 01:48:23 +00:00
Chris Lattner
685730f964
To not treat macro invocation locations as part of the include stack
...
when reporting a diagnostic.
llvm-svn: 38577
2006-06-26 01:36:22 +00:00
Chris Lattner
269c232e67
implement #pragma GCC dependency
...
llvm-svn: 38574
2006-06-25 06:23:00 +00:00
Chris Lattner
55a60954f9
Implement #pragma GCC system_header
...
llvm-svn: 38569
2006-06-25 04:20:34 +00:00
Chris Lattner
1786217e0b
Finish implementation of #pragma once. Implement #pragma GCC poison.
...
llvm-svn: 38568
2006-06-24 22:12:56 +00:00
Chris Lattner
b876183219
implement the pragma handling infrastructure. The only pragma so far is
...
#pragma once, and it is not completely implemented.
llvm-svn: 38566
2006-06-24 21:31:03 +00:00
Chris Lattner
c899718274
Track which headers are system and non-C++-clean-system headers. Use this
...
information to print the 3/4 flags correctly on #line directives emitted
in -E mode.
llvm-svn: 38562
2006-06-22 05:52:16 +00:00
Chris Lattner
0c885f5581
Improve #line emission in -E mode to include file entry/exits. This is
...
still pretty hacky because it doesn't compute the 3/4 markers correctly.
llvm-svn: 38561
2006-06-21 06:50:18 +00:00
Chris Lattner
9a13bde643
Implement a new SourceManager::getSourceName method
...
llvm-svn: 38560
2006-06-21 04:57:09 +00:00
Chris Lattner
bb893c3d67
Update SourceManager::getLineNumber to return the correct line # for macro
...
instantiations.
llvm-svn: 38558
2006-06-21 03:27:29 +00:00
Chris Lattner
30709b038d
Implement a new type of FileID: FileIDInfo::MacroExpansion. For tokens that
...
came from a macro expansion, this allows us to keep track of both where the
character data came from and where the logical position of the token is (at
the expansion site). This implements Preprocessor/indent_macro.c, and
reduces the number of cpp iostream -E diffs vs GCC from 2589 to 2297.
llvm-svn: 38557
2006-06-21 03:01:55 +00:00
Chris Lattner
5f4b1ff9fd
Modify SourceManager to make way for future macro locations and #line support
...
no functionality change yet
llvm-svn: 38556
2006-06-20 05:02:40 +00:00
Chris Lattner
8bb4edb236
remove an extraneous method
...
llvm-svn: 38554
2006-06-18 16:37:30 +00:00
Chris Lattner
50b497e072
Rename LexerToken::getSourceLocation -> getLocation
...
llvm-svn: 38553
2006-06-18 16:32:35 +00:00
Chris Lattner
5b4876807a
Move the LexerToken definition out to LexerToken.h
...
llvm-svn: 38552
2006-06-18 16:28:59 +00:00
Chris Lattner
d01e291332
Make a fundamental change to the way we represent the location of LexerToken's.
...
Now, instead of keeping a pointer to the start of the token in memory, we keep the
start of the token as a SourceLocation node. This means that each LexerToken knows
the full include stack it was created with, and means that the LexerToken isn't
reliant on a "CurLexer" member to be around (lexer tokens would previously go out of
scope when their lexers were deallocated).
This simplifies several things, and forces good cleanup elsewhere. Now the
Preprocessor is the one that knows how to dump tokens/macros and is the one that
knows how to get the spelling of a token (it has all the context).
llvm-svn: 38551
2006-06-18 16:22:51 +00:00
Chris Lattner
7e0dd2b11f
Fix a fixme by passing language options into LexerToken::dump, instead of
...
relying on TheLexer.
llvm-svn: 38549
2006-06-18 07:44:41 +00:00
Chris Lattner
33ce7283ee
Change the token representation to take a Start and Length instead of a
...
Start/End pointer.
llvm-svn: 38548
2006-06-18 07:35:33 +00:00
Chris Lattner
1f5830546a
Make a method a static function
...
llvm-svn: 38543
2006-06-18 06:53:56 +00:00
Chris Lattner
7966aafd9b
Simplify an API
...
llvm-svn: 38541
2006-06-18 06:50:36 +00:00
Chris Lattner
cb28334ea4
Remove manual conditional error handling code.
...
llvm-svn: 38540
2006-06-18 06:48:37 +00:00
Chris Lattner
22eb972f38
Initial checkin of c-language parser
...
llvm-svn: 38539
2006-06-18 05:43:12 +00:00