summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Implementation of Embarcadero array type traitsJohn Wiegley2011-04-281-0/+9
| | | | | | | | | | Patch authored by John Wiegley. These are array type traits used for parsing code that employs certain features of the Embarcadero C++ compiler: __array_rank(T) and __array_extent(T, Dim). llvm-svn: 130351
* t/clang/type-traitsJohn Wiegley2011-04-271-0/+55
| | | | | | | | | | Patch authored by John Wiegley. These type traits are used for parsing code that employs certain features of the Embarcadero C++ compiler. Several of these constructs are also desired by libc++, according to its project pages (such as __is_standard_layout). llvm-svn: 130342
* Introduce a new parser annotation token for primary expressions. WhenDouglas Gregor2011-04-271-20/+12
| | | | | | | ClassifyName() builds a primary expression, generate one of these annotation tokens rather than jumping into the parser. llvm-svn: 130297
* t/clang/expr-traitsJohn Wiegley2011-04-251-0/+8
| | | | | | | | | Patch authored by David Abrahams. These two expression traits (__is_lvalue_expr, __is_rvalue_expr) are used for parsing code that employs certain features of the Embarcadero C++ compiler. llvm-svn: 130122
* Implement a new identifier-classification scheme where SemaDouglas Gregor2011-04-241-8/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | performs name lookup for an identifier and resolves it to a type/expression/template/etc. in the same step. This scheme is intended to improve both performance (by reducing the number of redundant name lookups for a given identifier token) and error recovery (by giving Sema a chance to correct type names before the parser has decided that the identifier isn't a type name). For example, this allows us to properly typo-correct type names at the beginning of a statement: t.c:6:3: error: use of undeclared identifier 'integer'; did you mean 'Integer'? integer *i = 0; ^~~~~~~ Integer t.c:1:13: note: 'Integer' declared here typedef int Integer; ^ Previously, we wouldn't give a Fix-It because the typo correction occurred after the parser had checked whether "integer" was a type name (via Sema::getTypeName(), which isn't allowed to typo-correct) and therefore decided to parse "integer * i = 0" as an expression. By typo-correcting earlier, we typo-correct to the type name Integer and parse this as a declaration. Moreover, in this context, we can also typo-correct identifiers to keywords, e.g., t.c:7:3: error: use of undeclared identifier 'vid'; did you mean 'void'? vid *p = i; ^~~ void and recover appropriately. Note that this is very much a work-in-progress. The new Sema::ClassifyName is only used for expression-or-declaration disambiguation in C at the statement level. The next steps will be to make this work for the same disambiguation in C++ (where functional-style casts make some trouble), then push it further into the parser to eliminate more redundant name lookups. Fixes <rdar://problem/7963833> for C and starts us down the path of <rdar://problem/8172000>. llvm-svn: 130082
* Add support for '__is_literal_type' spelling of the existingChandler Carruth2011-04-241-0/+1
| | | | | | | | '__is_literal' type trait for GCC compatibility. At least one relased version if libstdc++ uses this name for the trait despite it not being documented anywhere. llvm-svn: 130078
* Implement basic __is_trivial type-trait support, enough to close PR9472.Chandler Carruth2011-04-231-0/+2
| | | | | | | | | | | | | | | | | | This introduces a few APIs on the AST to bundle up the standard-based logic so that programmatic clients have access to exactly the same behavior. There is only one serious FIXME here: checking for non-trivial move constructors and move assignment operators. Those bits need to be added to the declaration and accessors provided. This implementation should be enough for the uses of __is_trivial in libstdc++ 4.6's C++98 library implementation. Ideas for more thorough test cases or any edge cases missing would be appreciated. =D llvm-svn: 130057
* Sort the type traits in a few places where they weren't previouslyChandler Carruth2011-04-231-5/+5
| | | | | | sorted in order to prepare for adding some new ones. llvm-svn: 130056
* C1X: implement generic selectionsPeter Collingbourne2011-04-151-0/+98
| | | | | | | As an extension, generic selection support has been added for all supported languages. The syntax is the same as for C1X. llvm-svn: 129554
* Diagnose a missing ')' on what looks like a statement expression.John McCall2011-04-061-1/+6
| | | | | | | A situation where we can get an invalid ExprResult without an error. Fixes PR8394. Patch by Justin Bogner! llvm-svn: 128979
* Insomniac refactoring: change how the parser allocates attributes so thatJohn McCall2011-03-241-10/+10
| | | | | | | | | AttributeLists do not accumulate over the lifetime of parsing, but are instead reused. Also make the arguments array not require a separate allocation, and make availability attributes store their stuff in augmented memory, too. llvm-svn: 128209
* Make sure that we always pop a function's scope *before* we callDouglas Gregor2011-03-161-0/+1
| | | | | | | | | | | ActOnFinishFunctionBody/ActOnBlockStmtExpr. This way, we ensure that we diagnose undefined labels before the jump-scope checker gets run, since the jump-scope checker requires (as its invariant) that all of the GotoStmts be wired up correctly. Fixes PR9495. llvm-svn: 127738
* Add support for the OpenCL vec_step operator, by generalising andPeter Collingbourne2011-03-111-28/+41
| | | | | | | extending the existing support for sizeof and alignof. Original patch by Guy Benyei. llvm-svn: 127475
* Propagate new-style exception spec information to Declarator.Sebastian Redl2011-03-051-2/+3
| | | | llvm-svn: 127111
* Push nested-name-specifier source-location information into dependentDouglas Gregor2011-03-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | template specialization types. This also required some parser tweaks, since we were losing track of the nested-name-specifier's source location information in several places in the parser. Other notable changes this required: - Sema::ActOnTagTemplateIdType now type-checks and forms the appropriate type nodes (+ source-location information) for an elaborated-type-specifier ending in a template-id. Previously, we used a combination of ActOnTemplateIdType and ActOnTagTemplateIdType that resulted in an ElaboratedType wrapped around a DependentTemplateSpecializationType, which duplicated the keyword ("class", "struct", etc.) and nested-name-specifier storage. - Sema::ActOnTemplateIdType now gets a nested-name-specifier, which it places into the returned type-source location information. - Sema::ActOnDependentTag now creates types with source-location information. llvm-svn: 126808
* fix rdar://9024687, a crash on invalid that we used to silently ignore.Chris Lattner2011-02-181-0/+3
| | | | llvm-svn: 125962
* Switch labels over to using normal name lookup, instead of their Chris Lattner2011-02-181-2/+3
| | | | | | | own weird little DenseMap. Hey look, we now emit unused label warnings deterministically, amazing. llvm-svn: 125813
* When Parser::ParseExpressionList isn't given a completer, fall back toDouglas Gregor2011-02-171-0/+2
| | | | | | | normal "expression" completion. Fixes the most annoying code-completion bug I've found. llvm-svn: 125715
* When we encounter an Objective-C class name in an expression, followedDouglas Gregor2011-02-151-5/+10
| | | | | | | by the code completion token, treat this as a class message send where the opening square bracket is missing. Fixes <rdar://problem/6970911>. llvm-svn: 125587
* Parse: add support for parsing CUDA kernel callsPeter Collingbourne2011-02-091-10/+55
| | | | llvm-svn: 125219
* Implement the Microsoft __is_convertible_to type trait, modeling theDouglas Gregor2011-01-271-2/+4
| | | | | | | | | | semantics after the C++0x is_convertible type trait. This implementation is not 100% complete, because it allows access errors to be hard errors (rather than just evaluating false). Original patch by Steven Watanabe! llvm-svn: 124425
* Rvalue references for *this: parse ref-qualifiers.Douglas Gregor2011-01-261-0/+1
| | | | llvm-svn: 124276
* Add support for explicit constructor calls in Microsoft mode.Francois Pichet2011-01-181-1/+3
| | | | | | | | | | | | | | | | | | | For example: class A{ public: A& operator=(const A& that) { if (this != &that) { this->A::~A(); this->A::A(that); // <=== explicit constructor call. } return *this; } }; More work will be needed to support an explicit call to a template constructor. llvm-svn: 123735
* Fix warnings found by gcc-4.6, from -Wunused-but-set-variable andJeffrey Yasskin2011-01-181-2/+1
| | | | | | -Wint-to-pointer-cast. llvm-svn: 123719
* Implement the sizeof...(pack) expression to compute the length of aDouglas Gregor2011-01-041-0/+42
| | | | | | | | | parameter pack. Note that we're missing proper libclang support for the new SizeOfPackExpr expression node. llvm-svn: 122813
* Implement support for pack expansions in initializer lists andDouglas Gregor2011-01-031-6/+8
| | | | | | expression lists. llvm-svn: 122764
* Refactor how we collect attributes during parsing, and add slots for attributesJohn McCall2010-12-241-19/+8
| | | | | | | on array and function declarators. This is pretty far from complete, and I'll revisit it later if someone doesn't beat me to it. llvm-svn: 122535
* Remove the TypesCompatibleExprClass AST node. Merge its functionality into ↵Francois Pichet2010-12-081-20/+1
| | | | | | BinaryTypeTraitExpr. llvm-svn: 121298
* Type traits intrinsic implementation: __is_base_of(T, U)Francois Pichet2010-12-071-0/+3
| | | | | | New AST node introduced: BinaryTypeTraitExpr; to be reused for more intrinsics. llvm-svn: 121074
* Fix the source range of CXXNewExprs. Fixes http://llvm.org/pr8661.Nico Weber2010-11-221-2/+2
| | | | llvm-svn: 119966
* Provide code completion for types after the '^' that starts a blockDouglas Gregor2010-10-181-0/+5
| | | | | | literal. llvm-svn: 116754
* When we have two identifiers in a row in Objective-C, make sure toDouglas Gregor2010-09-281-1/+1
| | | | | | | | verify that we aren't in a message-send expression before digging into the identifier or looking ahead more tokens. Fixes a regression (<rdar://problem/8483253>) I introduced with bracket insertion. llvm-svn: 114968
* Continue parsing more postfix expressions, even after semanticDouglas Gregor2010-09-181-29/+18
| | | | | | errors. Improves code completion in yet another case. llvm-svn: 114255
* Improve recovery when the middle expression of a ternary operator is ill-formedDouglas Gregor2010-09-171-2/+4
| | | | llvm-svn: 114231
* When we run into an error parsing or type-checking the left-hand sideDouglas Gregor2010-09-171-24/+16
| | | | | | | | | | | | | | | | | | | | | | | of a binary expression, continue on and parse the right-hand side of the binary expression anyway, but don't call the semantic actions to type-check. Previously, we would see the error and then, effectively, skip tokens until the end of the statement. The result should be more useful recovery, both in the normal case (we'll actually see errors beyond the first one in a statement), but it also helps code completion do a much better job, because we do "real" code completion on the right-hand side of an invalid binary expression rather than completing with the recovery completion. For example, given x = p->y if there is no variable named "x", we can still complete after the p-> as a member expression. Along the recovery path, we would have completed after the "->" as if we were in an expression context, which is mostly useless. llvm-svn: 114225
* rename variable, 'Type' seems to be present inGabor Greif2010-09-171-3/+3
| | | | | | the enclosing scope, which confuses gcc v3.4 to no end llvm-svn: 114174
* Implement automatic bracket insertion for Objective-C class messageDouglas Gregor2010-09-161-2/+56
| | | | | | | | | | | | | | | | sends. These are far trickier than instance messages, because we typically have something like NSArray alloc] where it appears to be a declaration of a variable named "alloc" up until we see the ']' (or a ':'), and at that point we can't backtrace. So, we use a combination of syntactic and semantic disambiguation to treat this as a message send only when the type is an Objective-C type and it has the syntax of a class message send (which would otherwise be ill-formed). llvm-svn: 114057
* Handle bracket insertion for Objective-C class messages in a veryDouglas Gregor2010-09-151-37/+49
| | | | | | | | | | | narrow, almost useless case where we're inside a parenthesized expression, e.g., (NSArray alloc]) The solution to the general case still eludes me. llvm-svn: 114039
* Improve code completion for Objective-C message sends when the openingDouglas Gregor2010-09-151-4/+15
| | | | | | | | | | | | | | | | | | | | | | | '[' is missing. Prior commits improving recovery also improved code completion beyond the first selector, e.g., at or after the "to" in calculator add:x to:y but not after "calculator". We now provide the same completions for calculator <CC> that we would for [calculator <CC> if "calculator" is an expression whose type is something that can receive Objective-C messages. This code completion works for instance and super message sends, but not class message sends. llvm-svn: 113976
* Extend bracket insertion to message sends to "super", e.g.,Douglas Gregor2010-09-151-0/+12
| | | | | | | | super method:arg] will now recover nicely and insert the '[' before 'super'. llvm-svn: 113971
* Extend bracket insertion to handle nullary selectors, e.g.Douglas Gregor2010-09-151-1/+1
| | | | | | a getFoo] llvm-svn: 113969
* Implement bracket insertion for Objective-C instance message sends asDouglas Gregor2010-09-151-4/+29
| | | | | | | | | | | | | | | | | | | | | | | part of parser recovery. For example, given: a method1:arg]; we detect after parsing the expression "a" that we have the start of a message send expression. We pretend we've seen a '[' prior to the a, then parse the remainder as a message send. We'll then give a diagnostic+fix-it such as: fixit-objc-message.m:17:3: error: missing '[' at start of message send expression a method1:arg]; ^ [ The algorithm here is very simple, and always assumes that the open bracket goes at the beginning of the message send. It also only works for non-super instance message sends at this time. llvm-svn: 113968
* Introduce a new code-completion context for a parenthesizedDouglas Gregor2010-09-141-0/+8
| | | | | | | | expression, e.g., after the '(' that could also be a type cast. Here, we provide types as code-completion results in C/Objective-C (C++ already had them), although we wouldn't in a normal expression context. llvm-svn: 113904
* Eli helped me understand how evaluation contexts work.Sebastian Redl2010-09-101-0/+4
| | | | llvm-svn: 113642
* Parse the noexcept operator and stub out sema.Sebastian Redl2010-09-101-3/+17
| | | | llvm-svn: 113622
* Eliminate the comma locations from all of the Sema routines that dealDouglas Gregor2010-09-091-2/+1
| | | | | | | | with comma-separated lists. We never actually used the comma locations, nor did we store them in the AST, but we did manage to waste time during template instantiation to produce fake locations. llvm-svn: 113495
* Microsoft's __uuidof operator implementation part 1.Francois Pichet2010-09-081-0/+3
| | | | llvm-svn: 113356
* Implement __has_virtual_destructor. Patch by Steven Watanabe.Sebastian Redl2010-09-021-1/+2
| | | | llvm-svn: 112905
* Implement the __has_nothrow trait family, by Steven Watanabe.Sebastian Redl2010-08-311-3/+6
| | | | llvm-svn: 112577
* Revert my user-defined literal commits - r1124{58,60,67} pendingAlexis Hunt2010-08-301-2/+1
| | | | | | some issues being sorted out. llvm-svn: 112493
OpenPOWER on IntegriCloud