Commit Graph

442 Commits

Author SHA1 Message Date
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 08f2791bdc update comment
llvm-svn: 39151
2006-11-09 06:34:47 +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 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 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 7014fb8f07 need to add scope for arguments, but now is not the right time.
llvm-svn: 39125
2006-11-05 07:36:23 +00:00
Chris Lattner da59c2f161 Move objc productions to their own .cpp file.
llvm-svn: 39124
2006-11-05 02:08:13 +00:00
Chris Lattner 40f16b5d26 improve objc comments
llvm-svn: 39123
2006-11-05 02:05:37 +00:00
Chris Lattner 301cd76b8c silence warning
llvm-svn: 39115
2006-11-04 20:32:01 +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 eb2feefb46 implement some todo's: invoke the actions module for identifiers leading
expressions in stmt contexts.

llvm-svn: 39112
2006-11-04 19:14:32 +00:00
Chris Lattner 834618de6f replace some ugly alloca/malloc code with a couple of SmallString's.
llvm-svn: 39103
2006-11-03 07:48:41 +00:00
Chris Lattner 64b09ee57a improve comment, fit to 80 cols
llvm-svn: 39101
2006-11-03 07:35:12 +00:00
Chris Lattner 70058dda70 Emit:
test.m:2:14: error: expected ';' after @class
@ class foo  int x;
             ^

instead of silently accepting the malformed input.

llvm-svn: 39100
2006-11-03 07:32:21 +00:00
Chris Lattner aacc5af2c0 Fix case stmts to not fall through, rename methods, assert on unimplemented
pieces, emit a diagnostic like this:

test.m:4:1: error: unexpected '@' in program
@ foo;
^

llvm-svn: 39099
2006-11-03 07:21:07 +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 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 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 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 64408c7107 Compoundstmts imply a scope, track it. This implements
test/Parser/CompoundStmtScope.c

llvm-svn: 39042
2006-10-25 03:15:33 +00:00
Chris Lattner b1072a3df5 remove empty file
llvm-svn: 39039
2006-10-25 03:07:01 +00:00
Chris Lattner 4daa077a5c accept the __extension__ prefix expr
llvm-svn: 39018
2006-10-20 05:03:44 +00:00
Chris Lattner 1f496804d5 silence a warning
llvm-svn: 39007
2006-10-18 04:02:28 +00:00
Chris Lattner b95cca0d33 fix test/Parser/attributes.c
llvm-svn: 39001
2006-10-17 03:01:08 +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 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 b5600a6aa8 Parse ?:'s right
llvm-svn: 38961
2006-10-06 05:40:05 +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 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 6d28d9b428 Invoke actions for postfix exprs
llvm-svn: 38942
2006-08-24 03:51:22 +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 38ba3363ef Hook up more of the ASTStreamer
llvm-svn: 38936
2006-08-17 07:04:37 +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 0116c478e6 Implement asm statement parsing.
llvm-svn: 38929
2006-08-15 06:03:28 +00:00
Chris Lattner 5646b3e21c Fix test/Parser/types.c
llvm-svn: 38928
2006-08-15 05:12:01 +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 e37e2336b4 Parse attributes in all places allowed.
llvm-svn: 38925
2006-08-15 04:50:22 +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 15a00da679 Allow ExpectAndConsume to be used with any token.
llvm-svn: 38923
2006-08-15 04:10:31 +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 8a3e918e33 Correctly implement the check for a typedef name
llvm-svn: 38921
2006-08-14 15:44:00 +00:00
Chris Lattner 0fb8b36808 "enum x" really is a type specifier
llvm-svn: 38920
2006-08-14 01:30:12 +00:00
Chris Lattner ffe65b3ffd Implement scope tracking for empty-action.
llvm-svn: 38919
2006-08-14 01:28:29 +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 f0f3baa12e Inform actions about parsed declarators.
llvm-svn: 38910
2006-08-14 00:15:20 +00:00
Chris Lattner e4e38595b0 Add methods for scope manipulation.
llvm-svn: 38909
2006-08-14 00:15:05 +00:00
Chris Lattner b8bbad7fd1 Set TypeSpecType on 'struct x' with no body.
llvm-svn: 38904
2006-08-13 22:21:02 +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 e7dab44cab improve comment.
llvm-svn: 38901
2006-08-13 21:54:51 +00:00
Chris Lattner 8693a519d4 Implement initializer parsering.
llvm-svn: 38900
2006-08-13 21:54:02 +00:00
Chris Lattner 0e89462b08 Parse things like 'struct X;'
llvm-svn: 38898
2006-08-13 19:58:17 +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 0be454e182 Use ExpectAndConsume more
llvm-svn: 38895
2006-08-12 19:30:51 +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 9fab3b9486 Implement parsing of 'int A[X];' by tying into the expression parsing code.
Turn a bunch of fixme's into todo's.

llvm-svn: 38888
2006-08-12 18:25:42 +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 ce7e21da7a Implement ParseAssignmentExpression correctly
llvm-svn: 38884
2006-08-12 17:22:40 +00:00
Chris Lattner 3af6b8b9dc remove bogus fixme
llvm-svn: 38883
2006-08-12 17:21:27 +00:00
Chris Lattner 89d53752f5 Fix parsing of assignment expressions and handling of right-associative
things.

llvm-svn: 38881
2006-08-12 17:18:19 +00:00
Chris Lattner 96c3deb53d Simplify handling of the ternary operator even more. Now it just looks like
any average right-associative operator to most of the code.

llvm-svn: 38880
2006-08-12 17:13:08 +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 a0927cecb5 Improve diagnostics on cases like:
return a ? `  a;

After the expression is diagnosed, skip to the ';', so that the lack of
semicolon is not also diagnosed.

llvm-svn: 38877
2006-08-12 16:59:03 +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 b7f1fc95d3 cleanups, better comments.
llvm-svn: 38875
2006-08-12 16:45:01 +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 5bd57e0c73 Significant improvements to error recovery
llvm-svn: 38872
2006-08-11 06:40:25 +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 a092cd1f1b Implement parsing of casts, implementing Parser/statements.c:test6
llvm-svn: 38868
2006-08-11 01:38:28 +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 eb8a28f7b7 Rename some files
llvm-svn: 38855
2006-08-10 18:43:39 +00:00
Chris Lattner 2f9980ef14 Implement Parser/statements.c:test5: parsing decls that start with identifiers
in blocks.

llvm-svn: 38854
2006-08-10 18:39:24 +00:00
Chris Lattner 6dfd97806e Add support for simple labels.
llvm-svn: 38853
2006-08-10 18:31:37 +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 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 a350722189 comment cleanup
llvm-svn: 38837
2006-08-07 00:33:37 +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 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 1906f8087d Improve handling of [*]
llvm-svn: 38831
2006-08-06 19:14:46 +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 971c6b681a Add scaffolding for scopes.
llvm-svn: 38821
2006-08-05 22:46:42 +00:00
Chris Lattner d286488c5f Make error recovery "better"
llvm-svn: 38819
2006-08-05 08:09:44 +00:00
Chris Lattner d9c3c59fc0 Continue work on declspecs and declarations
llvm-svn: 38818
2006-08-05 06:26:47 +00:00
Chris Lattner 8e90ef6ccc add some notes
llvm-svn: 38817
2006-08-05 03:30:45 +00:00
Chris Lattner f63f89acc2 Handle __thread and storage-class-specifiers
llvm-svn: 38816
2006-08-05 03:28:50 +00:00
Chris Lattner 158ede8e44 Add a citation
llvm-svn: 38814
2006-08-04 06:42:38 +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 deb42f5a96 Add some missing assignments.
llvm-svn: 38808
2006-08-04 05:26:52 +00:00
Chris Lattner da48a8e66b Parse and validate cvr type-qualifiers
llvm-svn: 38807
2006-08-04 05:25:55 +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 c0acd3d621 Split declaration parsing out into Declarations.cpp
llvm-svn: 38804
2006-07-31 05:13:43 +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