Граф коммитов

26 Коммитов

Автор SHA1 Сообщение Дата
Sebastian Redl 9a92034270 Convert some more statement parsers to smart pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60892 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11 19:48:14 +00:00
Sebastian Redl 61364dddc3 Convert a number of statement parsers to smart pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60888 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-11 19:30:53 +00:00
Douglas Gregor caaf29a087 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60858 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-10 23:01:14 +00:00
Douglas Gregor 8935b8b490 Use a scoped object to manage entry/exit from a parser scope rather than explicitly calling EnterScope/ExitScope
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60830 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-10 06:34:36 +00:00
Sebastian Redl effa8d1c97 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60809 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-10 00:02:53 +00:00
Sebastian Redl 15faa7fdfb Kick out the proof-of-concept ASTOwner and replace it with ASTOwningResult
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60791 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 20:22:58 +00:00
Sebastian Redl 0e9eabca26 Consistently use smart pointers for stmt and expr nodes in parser local variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60761 91177308-0d34-0410-b5e6-96231b3b80d8
2008-12-09 13:15:23 +00:00
Sebastian Redl a55e52c080 Use RAII objects to ensure proper destruction of expression and statement AST nodes in the parser in most cases, even on error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60057 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 22:21:31 +00:00
Chris Lattner 28eb7e992b make the 'to match this' diagnostic a note.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59921 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-23 23:17:07 +00:00
Douglas Gregor 7425373618 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59638 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 15:42:04 +00:00
Chris Lattner 1ab3b96de1 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59509 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 07:48:38 +00:00
Chris Lattner 195044028b 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59256 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 18:52:53 +00:00
Chris Lattner 39146d6497 simplify some other code for __extension__ processing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57807 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-20 06:51:33 +00:00
Argyrios Kyrtzidis bbc70c019f Disambiguate between a declaration or an expression, in the 'for-init-statement' part of a 'for' statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57112 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 15:50:46 +00:00
Argyrios Kyrtzidis 5404a156be 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57084 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-05 00:06:24 +00:00
Argyrios Kyrtzidis 14d08c0c77 Add comments about C++ clause 3.3.2p4 that mentions that the condition declaration should be local to an if/switch/while/for statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56134 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-11 23:08:39 +00:00
Argyrios Kyrtzidis 143db71d8d Fix do-while scoping in C++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56095 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-11 04:46:46 +00:00
Argyrios Kyrtzidis 488d37e8c0 Revert r56078, getLang().C99 being true in C++ is a bug that will be fixed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56090 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-11 03:06:46 +00:00
Argyrios Kyrtzidis fe7e4f08fe -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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56078 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-10 23:46:08 +00:00
Argyrios Kyrtzidis 957163829d Add some C++-specific comments in the parsing methods of if/switch/while/for.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56060 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-10 17:38:35 +00:00
Argyrios Kyrtzidis 71b914b999 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56007 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-09 20:38:47 +00:00
Argyrios Kyrtzidis dcdd55fb4d Support C++'s declaration-statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55888 91177308-0d34-0410-b5e6-96231b3b80d8
2008-09-07 18:58:01 +00:00
Argyrios Kyrtzidis b9f930d7bd Use of NextToken() makes ParseIdentifierStatement unnecessary.
Simplify the parser by removing Parser::ParseIdentifierStatement.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53520 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-12 21:04:42 +00:00
Argyrios Kyrtzidis f7da726f09 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53376 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-09 22:53:07 +00:00
Steve Naroff d77bc28342 Have Parser::FuzzyParseMicrosoftAsmStatement() return the null statement (';').
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49349 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-07 21:06:54 +00:00
Chris Lattner bda0b626e7 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-15 23:59:48 +00:00