Commit Graph

60 Commits

Author SHA1 Message Date
Anders Carlsson 51873c22d8 Refactor switch analysis to make it possible to detect duplicate case values
llvm-svn: 40388
2007-07-22 07:07:56 +00:00
Chris Lattner e34b2c298a Catch goto's with a missing identifier, patch by Neil Booth.
llvm-svn: 40381
2007-07-22 04:13:33 +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 46eeb22fec Add initial switch stmt support, patch by Anders Carlsson!
llvm-svn: 39989
2007-07-18 02:28:47 +00:00
Chris Lattner 436806ad05 In code like this:
typedef float float4 __attribute__((vector_size (16)));
void addFloat4(float4 a, float4 b) {
    float4 temp;
}

make sure to add 'temp' to the stmt tree as a declstmt.

llvm-svn: 39722
2007-07-10 05:03:31 +00:00
Chris Lattner cd68f64551 Start bringing the exprstmt hook back.
llvm-svn: 39677
2007-06-27 01:06:29 +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 2e550fea6a When parsing an expr in stmt context, make sure to consume the semicolon
after the expr along with the expr.  If we don't do this, the semicolon
gets parsed as a nullstmt, which makes the generated AST very strange.

llvm-svn: 39600
2007-06-06 05:26:32 +00:00
Steve Naroff 0f2fe17ff1 Bug #:
Submitted by:
Reviewed by:
Implement support for GCC __attribute__.

- Implement "TODO" in Parser::ParseAttributes. Changed the return type from
void to Parser::DeclTy. Changed all call sites to accept the return value.
- Added Action::ParseAttribute and Sema::ParseAttribute to return an
appropriate AST node. Added new node AttributeDecl to Decl.h.

Still to do...hook up to the Decl...

llvm-svn: 39539
2007-06-01 17:11:19 +00:00
Steve Naroff 9992bbab14 Bug #:
Submitted by:
Reviewed by:
- ParseForStatement(): Put back a test/assignment. My removal of
ParseExprStmt() was a bit over zealous:-(thanks to Chris for pointing it out)
- Add assert to VisitDeclStmt().
- Removed an out-of-date FIXME
- Added some curlies for a couple multi-line calls to Diag().

llvm-svn: 39528
2007-05-30 16:27:15 +00:00
Steve Naroff 2a8ad18e71 Bug #:
Submitted by:
Reviewed by:
Implement some FIXME's that stand in the way of fully typechecking "for"
statements. This involved:

- Adding a DeclStmt AST node (with statement visitor). The DeclStmt
printer is preliminary.
- Added a ParseDeclStmt action, called from Parser::ParseForStatement()
and Parser::ParseStatementOrDeclaration(). DID NOT add to
Parser::ParseIdentifierStatement()...probably could have, however didn't
really understand the context of this rule (will speak with Chris).
- Removed ParseExprStmt (and it's clients)...it was vestigial.

llvm-svn: 39518
2007-05-29 22:59:26 +00:00
Chris Lattner 010015a11e Add a note about an unimplemented gnu extension.
llvm-svn: 39511
2007-05-28 07:23:54 +00:00
Chris Lattner eefa10e78a implement full sema support for the GCC address-of-label extension.
llvm-svn: 39510
2007-05-28 06:56:27 +00:00
Chris Lattner ac4471c963 Improve the parsers resilience to sematic errors. This allows us to turn:
void foo() {
  if (0) break;
  abc:
  def:
  hij:
    break;

into:

void foo() {
  if ((0)')
    ;
abc:
def:
hij:
  ;

instead of dropping the if and labels (due to break not being in a loop).

llvm-svn: 39508
2007-05-28 05:38:24 +00:00
Chris Lattner 0f203a7c1c add action for null stmt, create ast node.
llvm-svn: 39506
2007-05-28 01:45:28 +00:00
Chris Lattner 49252eb303 Implement a FIXME: when a typedef is seen at statement scope, make sure to
actually add it into the declspec for the type being parsed.  This allows us
to do correct semantic analysis on:

typedef int bar;
int foo() {
  bar a;
  return a;
}

This reduces # errors parsing carbon.h from 731 to 654.

llvm-svn: 39321
2007-01-27 19:04:39 +00:00
Chris Lattner f297880ff9 Split code out of ParseCompoundStatement into ParseCompoundStatementBody.
This fixes a bug where a missing } could cause the scope stacks to get
unbalanced and will be used for function body parsing.

llvm-svn: 39249
2007-01-21 06:52:16 +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 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 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 289ab7bb1d rename SemaDecl.cpp/h to SemaDeclSpec.cpp/h
llvm-svn: 39149
2006-11-08 06:54:53 +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 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 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
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 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 1f496804d5 silence a warning
llvm-svn: 39007
2006-10-18 04:02:28 +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 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 e550a4ea12 Build CastExpr AST nodes
llvm-svn: 38950
2006-08-24 06:37:51 +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 e37e2336b4 Parse attributes in all places allowed.
llvm-svn: 38925
2006-08-15 04:50:22 +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 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 0e89462b08 Parse things like 'struct X;'
llvm-svn: 38898
2006-08-13 19:58:17 +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 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 89c50c65af Return information about whether expression parsing was successful
llvm-svn: 38873
2006-08-11 06:41:18 +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 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 c5e0d4a6ae stub out some entry points for the expr parsing code.
llvm-svn: 38858
2006-08-10 19:06:03 +00:00