Commit Graph

47 Commits

Author SHA1 Message Date
Sebastian Redl 726a0d9524 Put the invalid flag of OwningResult into the Action pointer.
This shrinks OwningResult by one pointer. Since it is no longer larger than OwningPtr, merge the two.
This leads to simpler client code and speeds up my benchmark by 2.7%.
For some reason, this exposes a previously hidden bug, causing a regression in SemaCXX/condition.cpp.

llvm-svn: 63867
2009-02-05 15:02:23 +00:00
Eli Friedman eb3a9b03ab Fix for PR3418: make sure to handle the RHS of expressions starting with
__extension__.  This sort of construct shows up in the gcc source code.

llvm-svn: 63100
2009-01-27 08:43:38 +00:00
Sebastian Redl c215cfc3e1 Convert more expression actions to smart pointers.
Fix type of logical negation for C++.

llvm-svn: 62475
2009-01-19 00:08:26 +00:00
Sebastian Redl c2edafbdff Rename move_convert to move_arg and move_res. The new names are less misleading (and shorter).
llvm-svn: 62466
2009-01-18 18:03:53 +00:00
Sebastian Redl 24b8e15dfa Convert asm statement action to smart pointers.
llvm-svn: 62464
2009-01-18 16:53:17 +00:00
Sebastian Redl 573feed2a8 Convert more statement actions to smart pointers.
llvm-svn: 62463
2009-01-18 13:19:59 +00:00
Sebastian Redl fbfaafc0a9 Convert some more statement actions to smart pointers.
Fix a type error; parser wanted to pass the third part of a for-statement as a statement; should be expression.

llvm-svn: 62380
2009-01-16 23:28:06 +00:00
Chris Lattner 8a42586c54 more SourceLocation lexicon change: instead of referring to the
"logical" location, refer to the "instantiation" location.

llvm-svn: 62316
2009-01-16 07:36:28 +00:00
Sebastian Redl 6a8002eac7 Convert some more actions to smart pointers.
No performance regression in my basic test.
Also fixed a type error in ActOnFinishSwitchStmt's arguments (body is a stmt).

llvm-svn: 62032
2009-01-11 00:38:46 +00:00
Sebastian Redl 1cbb59182c Convert a two more statement actions to smart pointers.
llvm-svn: 61456
2008-12-28 16:13:43 +00:00
Sebastian Redl 54c04d4700 Partial AST and Sema support for C++ try-catch.
llvm-svn: 61337
2008-12-22 19:15:10 +00:00
Sebastian Redl b219c90d7b Parser support for C++ try-catch.
llvm-svn: 61312
2008-12-21 16:41:36 +00:00
Sebastian Redl 52f03bac60 Convert a few Stmt actions to smart pointers.
llvm-svn: 61309
2008-12-21 12:04:03 +00:00
Eli Friedman 44842d140f Do proper recovery from an invalid switch condiition. Fixes PR3229.
llvm-svn: 61160
2008-12-17 22:19:57 +00:00
Sebastian Redl c675baba92 Some utilities for using the smart pointers in Actions, especially Sema. Convert a few functions.
llvm-svn: 60983
2008-12-13 16:23:55 +00:00
Chris Lattner 10da53c60c use smarter error recovery for do/while.
llvm-svn: 60933
2008-12-12 06:35:28 +00:00
Chris Lattner c0081db332 apply the new error recovery smarts we have for if's to while's and switch's.
llvm-svn: 60932
2008-12-12 06:31:07 +00:00
Chris Lattner bc2d77cdf2 merge recovery-2.c into recovery-3.c.
Substantially improve error recovery after broken if conditions by
parsing the full if when we have a semantic error instead of using
parser recovery techniques to recover from a semantic error.

This fixes rdar://6094870 - spurious error after invalid 'if' condition

llvm-svn: 60929
2008-12-12 06:19:11 +00:00
Sebastian Redl 90893187c4 Convert some more expression parsers to use smart pointers.
llvm-svn: 60904
2008-12-11 22:33:27 +00:00
Sebastian Redl 59b5e517c7 Convert selected expression parsers to use smart pointers.
llvm-svn: 60900
2008-12-11 21:36:32 +00:00
Sebastian Redl bab9a4b5ea Convert the remaining statement parsers to smart pointers.
llvm-svn: 60895
2008-12-11 20:12:42 +00:00
Sebastian Redl b62406f6e4 Convert some more statement parsers to smart pointers.
llvm-svn: 60892
2008-12-11 19:48:14 +00:00
Sebastian Redl 042ad95d4e Convert a number of statement parsers to smart pointers.
llvm-svn: 60888
2008-12-11 19:30:53 +00:00
Douglas Gregor 85970ca84c Added a warning when referencing an if's condition variable in the
"else" clause, e.g.,

  if (int X = foo()) {
  } else {
    if (X) { // warning: X is always zero in this context
    }
  }

Fixes rdar://6425550 and lets me think about something other than
DeclContext.

llvm-svn: 60858
2008-12-10 23:01:14 +00:00
Douglas Gregor 7307d6ca96 Use a scoped object to manage entry/exit from a parser scope rather than explicitly calling EnterScope/ExitScope
llvm-svn: 60830
2008-12-10 06:34:36 +00:00
Sebastian Redl d9f7b1c230 Modify the move emulation according to the excellent design of Howard Hinnant. Makes for much nicer syntax when smart pointers are used consistently. Also, start converting internal argument passing of Parser to smart pointers.
llvm-svn: 60809
2008-12-10 00:02:53 +00:00
Sebastian Redl c13f26873f Kick out the proof-of-concept ASTOwner and replace it with ASTOwningResult
llvm-svn: 60791
2008-12-09 20:22:58 +00:00
Sebastian Redl 17f2c7d251 Consistently use smart pointers for stmt and expr nodes in parser local variables.
llvm-svn: 60761
2008-12-09 13:15:23 +00:00
Sebastian Redl 511ed55524 Use RAII objects to ensure proper destruction of expression and statement AST nodes in the parser in most cases, even on error.
llvm-svn: 60057
2008-11-25 22:21:31 +00:00
Chris Lattner 03c4041cb5 make the 'to match this' diagnostic a note.
llvm-svn: 59921
2008-11-23 23:17:07 +00:00
Douglas Gregor d08452f60a Added operator overloading for unary operators, post-increment, and
post-decrement, including support for generating all of the built-in
operator candidates for these operators. 

C++ and C have different rules for the arguments to the builtin unary
'+' and '-'. Implemented both variants in Sema::ActOnUnaryOp.

In C++, pre-increment and pre-decrement return lvalues. Update
Expr::isLvalue accordingly.

llvm-svn: 59638
2008-11-19 15:42:04 +00:00
Chris Lattner 6d29c10564 Change a couple of the Parser::Diag methods to return DiagnosticInfo
and let the clients push whatever they want into the DiagnosticInfo
instead of hard coding a few forms.  Also switch various clients to
use Diag(Tok, ...) instead of Diag(Tok.getLocation(), ...) as the
canonical form to simplify the code a bit.

llvm-svn: 59509
2008-11-18 07:48:38 +00:00
Chris Lattner 0046de17e5 Fix a couple of suboptimalities in error recovery.
1. In the top level of ParseStatementOrDeclaration, don't eat a } if we
   just parsed a statement if it list there.  Also, don't even bother
   emitting an error about a missing semicolon if the statement had a 
   bug (an rbrace is fine).
2. In do/while parsing, don't require a 'while' to be present if the do
   body didn't parse.

This allows us to generate a clean diagnostic for this code:

t.c:1:22: error: expected expression
void foo (void) { do . while (0); }
                     ^

Thanks to Neil for pointing this out.

llvm-svn: 59256
2008-11-13 18:52:53 +00:00
Chris Lattner 1ff6e73651 simplify some other code for __extension__ processing.
llvm-svn: 57807
2008-10-20 06:51:33 +00:00
Argyrios Kyrtzidis bc28fefcde Disambiguate between a declaration or an expression, in the 'for-init-statement' part of a 'for' statement.
llvm-svn: 57112
2008-10-05 15:50:46 +00:00
Argyrios Kyrtzidis 2c7137d8d1 Resolve ambiguous C++ statements (C++ 6.8p1).
'ParseTentative.cpp' implements the functionality needed to resolve ambiguous C++ statements, to either a declaration or an expression, by "tentatively parsing" them.

llvm-svn: 57084
2008-10-05 00:06:24 +00:00
Argyrios Kyrtzidis 47f9865182 Add comments about C++ clause 3.3.2p4 that mentions that the condition declaration should be local to an if/switch/while/for statement.
llvm-svn: 56134
2008-09-11 23:08:39 +00:00
Argyrios Kyrtzidis fea38016a9 Fix do-while scoping in C++.
llvm-svn: 56095
2008-09-11 04:46:46 +00:00
Argyrios Kyrtzidis 504bb844ba Revert r56078, getLang().C99 being true in C++ is a bug that will be fixed.
llvm-svn: 56090
2008-09-11 03:06:46 +00:00
Argyrios Kyrtzidis 48dea3b9f5 -getLang().C99 is true in C++ too, remove the use of the C99orCXX variable.
-Scoping in C99 works good for C++ too, remove the C++-specific comments.

If someone thinks that the C++-specific comments are necessary for clarification, let me know and I'll put them back on.

llvm-svn: 56078
2008-09-10 23:46:08 +00:00
Argyrios Kyrtzidis eece3fe4fd Add some C++-specific comments in the parsing methods of if/switch/while/for.
llvm-svn: 56060
2008-09-10 17:38:35 +00:00
Argyrios Kyrtzidis 2b4072fe55 Implement parser support for the 'condition' part of C++ selection-statements and iteration-statements (if/switch/while/for).
Add new 'ActOnCXXConditionDeclarationExpr' action, called when the 'condition' is a declaration instead of an expression.

llvm-svn: 56007
2008-09-09 20:38:47 +00:00
Argyrios Kyrtzidis dee8291a14 Support C++'s declaration-statement.
llvm-svn: 55888
2008-09-07 18:58:01 +00:00
Argyrios Kyrtzidis 07b8b63f9f Use of NextToken() makes ParseIdentifierStatement unnecessary.
Simplify the parser by removing Parser::ParseIdentifierStatement.

llvm-svn: 53520
2008-07-12 21:04:42 +00:00
Argyrios Kyrtzidis 832e898803 Simplify the parser a bit by looking at the next token without consuming it (by Preprocessor::LookNext):
-Remove ParseExpressionWithLeadingIdentifier and ParseAssignmentExprWithLeadingIdentifier.
-Separate ParseLabeledStatement from ParseIdentifierStatement.

llvm-svn: 53376
2008-07-09 22:53:07 +00:00
Steve Naroff fba3942438 Have Parser::FuzzyParseMicrosoftAsmStatement() return the null statement (';').
llvm-svn: 49349
2008-04-07 21:06:54 +00:00
Chris Lattner 7a51313d8a Make a major restructuring of the clang tree: introduce a top-level
lib dir and move all the libraries into it.  This follows the main
llvm tree, and allows the libraries to be built in parallel.  The
top level now enforces that all the libs are built before Driver,
but we don't care what order the libs are built in.  This speeds
up parallel builds, particularly incremental ones.

llvm-svn: 48402
2008-03-15 23:59:48 +00:00