summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Some minor comments modifications.Argyrios Kyrtzidis2009-05-221-2/+2
| | | | | | There are no unnecessary action calls period (courtesy of the annotation scheme) and too many 'this means'.. llvm-svn: 72263
* Handle correctly a very ugly part of the C++ syntax. We cannot disambiguate ↵Argyrios Kyrtzidis2009-05-221-0/+107
| | | | | | | | | | | | | | between a parenthesized type-id and a paren expression without considering the context past the parentheses. Behold: (T())x; - type-id (T())*x; - type-id (T())/x; - expression (T()); - expression llvm-svn: 72260
* Remove ParseSimpleParenExpression.Argyrios Kyrtzidis2009-05-221-3/+12
| | | | | | | | Embed its functionality into it's only user, ParseCXXCasts. CXXCasts now get the "actual" expression directly, they no longer always receive a ParenExpr. This is better since the parentheses are always part of the C++ casts syntax. llvm-svn: 72257
* Merge the ASTVector and ASTOwningVector templates, since they offeredDouglas Gregor2009-05-211-1/+0
| | | | | | | | redundant functionality. The result (ASTOwningVector) lives in clang/Parse/Ownership.h and is used by both the parser and semantic analysis. No intended functionality change. llvm-svn: 72214
* Use v.data() instead of &v[0] when SmallVector v might be empty.Jay Foad2009-05-211-1/+1
| | | | llvm-svn: 72210
* Implement explicit instantiations of member classes of class templates, e.g.,Douglas Gregor2009-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | template<typename T> struct X { struct Inner; }; template struct X<int>::Inner; This change is larger than it looks because it also fixes some a problem with nested-name-specifiers and tags. We weren't requiring the DeclContext associated with the scope specifier of a tag to be complete. Therefore, when looking for something like "struct X<int>::Inner", we weren't instantiating X<int>. This, naturally, uncovered a problem with member pointers, where we were requiring the left-hand side of a member pointer access expression (e.g., x->*) to be a complete type. However, this is wrong: the semantics of this expression does not require a complete type (EDG agrees). Stuart vouched for me. Blame him. llvm-svn: 71756
* This is a pretty big cleanup for how invalid decl/type are handle.Chris Lattner2009-04-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This gets rid of a bunch of random InvalidDecl bools in sema, changing us to use the following approach: 1. When analyzing a declspec or declarator, if an error is found, we set a bit in Declarator saying that it is invalid. 2. Once the Decl is created by sema, we immediately set the isInvalid bit on it from what is in the declarator. From this point on, sema consistently looks at and sets the bit on the decl. This gives a very clear separation of concerns and simplifies a bunch of code. In addition to this, this patch makes these changes: 1. it renames DeclSpec::getInvalidType() -> isInvalidType(). 2. various "merge" functions no longer return bools: they just set the invalid bit on the dest decl if invalid. 3. The ActOnTypedefDeclarator/ActOnFunctionDeclarator/ActOnVariableDeclarator methods now set invalid on the decl returned instead of returning an invalid bit byref. 4. In SemaType, refering to a typedef that was invalid now propagates the bit into the resultant type. Stuff declared with the invalid typedef will now be marked invalid. 5. Various methods like CheckVariableDeclaration now return void and set the invalid bit on the decl they check. There are a few minor changes to tests with this, but the only major bad result is test/SemaCXX/constructor-recovery.cpp. I'll take a look at this next. llvm-svn: 70020
* Add code modification hints to various parsing-related diagnostics.Douglas Gregor2009-04-011-2/+2
| | | | | | | Plus, reword a extension warnings to avoid talking about "ISO C" when the extension might also be available in C++ or C++0x. llvm-svn: 68257
* Make parsing a semantic analysis a little more robust following SemaDouglas Gregor2009-04-011-9/+11
| | | | | | | | | | | | | | | | failures that involve malformed types, e.g., "typename X::foo" where "foo" isn't a type, or "std::vector<void>" that doens't instantiate properly. Similarly, be a bit smarter in our handling of ambiguities that occur in Sema::getTypeName, to eliminate duplicate error messages about ambiguous name lookup. This eliminates two XFAILs in test/SemaCXX, one of which was crying out to us, trying to tell us that we were producing repeated error messages. llvm-svn: 68251
* Parsing and AST representation for dependent template names that occurDouglas Gregor2009-03-311-18/+18
| | | | | | | | | | | within nested-name-specifiers, e.g., for the "apply" in typename MetaFun::template apply<T1, T2>::type At present, we can't instantiate these nested-name-specifiers, so our testing is sketchy. llvm-svn: 68081
* Improve the representation of template names in the AST. ThisDouglas Gregor2009-03-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | representation handles the various ways in which one can name a template, including unqualified references ("vector"), qualified references ("std::vector"), and dependent template names ("MetaFun::template apply"). One immediate effect of this change is that the representation of nested-name-specifiers in type names for class template specializations (e.g., std::vector<int>) is more accurate. Rather than representing std::vector<int> as std::(vector<int>) we represent it as (std::vector)<int> which more closely follows the C++ grammar. Additionally, templates are no longer represented as declarations (DeclPtrTy) in Parse-Sema interactions. Instead, I've introduced a new OpaquePtr type (TemplateTy) that holds the representation of a TemplateName. This will simplify the handling of dependent template-names, once we get there. llvm-svn: 68074
* Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for aChris Lattner2009-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | pointer. Its purpose in life is to be a glorified void*, but which does not implicitly convert to void* or other OpaquePtr's with a different UID. Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>. Change the entire parser/sema interface to use DeclPtrTy instead of DeclTy*. This makes the C++ compiler enforce that these aren't convertible to other opaque types. We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc, but I don't plan to do that in the short term. The one outstanding known problem with this patch is that we lose the bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to bitmangle the success bit into the low bit of DeclPtrTy. I will rectify this with a subsequent patch. llvm-svn: 67952
* Simplify CXXScopeSpec a lot. No more weird SmallVector-like hacks hereDouglas Gregor2009-03-261-5/+4
| | | | llvm-svn: 67800
* Introduce a representation for types that we referred to via aDouglas Gregor2009-03-191-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qualified name, e.g., foo::x so that we retain the nested-name-specifier as written in the source code and can reproduce that qualified name when printing the types back (e.g., in diagnostics). This is PR3493, which won't be complete until finished the other tasks mentioned near the end of this commit. The parser's representation of nested-name-specifiers, CXXScopeSpec, is now a bit fatter, because it needs to contain the scopes that precede each '::' and keep track of whether the global scoping operator '::' was at the beginning. For example, we need to keep track of the leading '::', 'foo', and 'bar' in ::foo::bar::x The Action's CXXScopeTy * is no longer a DeclContext *. It's now the opaque version of the new NestedNameSpecifier, which contains a single component of a nested-name-specifier (either a DeclContext * or a Type *, bitmangled). The new sugar type QualifiedNameType composes a sequence of NestedNameSpecifiers with a representation of the type we're actually referring to. At present, we only build QualifiedNameType nodes within Sema::getTypeName. This will be extended to other type-constructing actions (e.g., ActOnClassTemplateId). Also on the way: QualifiedDeclRefExprs will also store a sequence of NestedNameSpecifiers, so that we can print out the property nested-name-specifier. I expect to also use this for handling dependent names like Fibonacci<I - 1>::value. llvm-svn: 67265
* Convert a bunch of actions to smart pointers, and also bring ↵Sebastian Redl2009-03-151-20/+17
| | | | | | PrintParserCallbacks a bit more in line with reality. llvm-svn: 67029
* Implement parsing of nested-name-specifiers that involve template-ids, e.g.,Douglas Gregor2009-02-251-21/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::vector<int>::allocator_type When we parse a template-id that names a type, it will become either a template-id annotation (which is a parsed representation of a template-id that has not yet been through semantic analysis) or a typename annotation (where semantic analysis has resolved the template-id to an actual type), depending on the context. We only produce a type in contexts where we know that we only need type information, e.g., in a type specifier. Otherwise, we create a template-id annotation that can later be "upgraded" by transforming it into a typename annotation when the parser needs a type. This occurs, for example, when we've parsed "std::vector<int>" above and then see the '::' after it. However, it means that when writing something like this: template<> class Outer::Inner<int> { ... }; We have two tokens to represent Outer::Inner<int>: one token for the nested name specifier Outer::, and one template-id annotation token for Inner<int>, which will be passed to semantic analysis to define the class template specialization. Most of the churn in the template tests in this patch come from an improvement in our error recovery from ill-formed template-ids. llvm-svn: 65467
* Update Parser::ParseTypeName to return a TypeResult, which also tellsDouglas Gregor2009-02-181-8/+12
| | | | | | | | us whether there was an error in trying to parse a type-name (type-id in C++). This allows propagation of errors further in the compiler, suppressing more bogus error messages. llvm-svn: 64922
* Implement Declarator::getSourceRange().Sebastian Redl2009-02-091-12/+43
| | | | llvm-svn: 64151
* Make Sema::getTypeName return the opaque pointer of a QualType ratherDouglas Gregor2009-02-091-1/+1
| | | | | | | | | | | | | | | | than a Decl, which gives us some more flexibility to express the results with the type system. There are no clients using this flexibility yet, but it's meant to be able to describe qualified names as written in the source (e.g., "foo::type") or template-ids that name a class template specialization (e.g., "std::vector<INT>"). DeclSpec's TST_typedef has become TST_typename, to reflect its use to describe types found by name (that may or may not be typedefs). The type representation of a DeclSpec with TST_typename is an opaque QualType pointer. All users of TST_typedef, both direct and indirect, have been updated for these changes. llvm-svn: 64141
* Allow taking the address of data members, resulting in a member pointer.Sebastian Redl2009-02-031-5/+12
| | | | | | Pointers to functions don't work yet, and pointers to overloaded functions even less. Also, far too much illegal code is accepted. llvm-svn: 63655
* move library-specific diagnostic headers into library private dirs. ReduceChris Lattner2009-01-291-1/+1
| | | | | | redundant #includes. Patch by Anders Johnsen! llvm-svn: 63271
* Split the single monolithic DiagnosticKinds.def file into oneChris Lattner2009-01-271-1/+1
| | | | | | | | | .def file for each library. This means that adding a diagnostic to sema doesn't require all the other libraries to be rebuilt. Patch by Anders Johnsen! llvm-svn: 63111
* Some micro-optimizations for DISABLE_SMART_POINTERS:Douglas Gregor2009-01-261-3/+3
| | | | | | | | | | | | | | | | | - When it's safe, ActionResult uses the low bit of the pointer for the "invalid" flag rather than a separate "bool" value. This keeps GCC from generating some truly awful code, for a > 3x speedup in the result-passing microbenchmark. - When DISABLE_SMART_POINTERS is defined, store an ActionResult within ASTOwningResult rather than an ASTOwningPtr. Brings the performance benefits of the above to smart pointers with DISABLE_SMART_POINTERS defined. Sadly, these micro-benchmark performance improvements don't seem to make much of a difference on Cocoa.h right now. However, they're harmless and might help with future optimizations. llvm-svn: 63061
* Convert a few expression actions to smart pointers.Sebastian Redl2009-01-181-7/+6
| | | | | | These actions are extremely widely used (identifier expressions and literals); still no performance regression. llvm-svn: 62468
* Add whitespace to silence the following warning in a Release build: warning: ↵Ted Kremenek2009-01-061-1/+1
| | | | | | suggest a space before ';' or explicit braces around empty body in 'while' statement llvm-svn: 61820
* rename MaybeParseCXXScopeSpecifier -> ParseOptionalCXXScopeSpecifier and Chris Lattner2009-01-061-8/+9
| | | | | | MaybeParseTypeSpecifier -> ParseOptionalTypeSpecifier. llvm-svn: 61796
* rename tok::annot_qualtypename -> tok::annot_typename, which is bothChris Lattner2009-01-061-2/+2
| | | | | | shorter and more accurate. The type name might not be qualified. llvm-svn: 61788
* PODness and Type TraitsSebastian Redl2009-01-051-0/+48
| | | | | | | | | | | | | | | Make C++ classes track the POD property (C++ [class]p4) Track the existence of a copy assignment operator. Implicitly declare the copy assignment operator if none is provided. Implement most of the parsing job for the G++ type traits extension. Fully implement the low-hanging fruit of the type traits: __is_pod: Whether a type is a POD. __is_class: Whether a type is a (non-union) class. __is_union: Whether a type is a union. __is_enum: Whether a type is an enum. __is_polymorphic: Whether a type is polymorphic (C++ [class.virtual]p1). llvm-svn: 61746
* remove optimization to avoid looking ahead for cases like ::foo. ThisChris Lattner2009-01-051-25/+7
| | | | | | isn't worth the complexity and the code already does a ton of lookahead. llvm-svn: 61671
* simplify some code.Chris Lattner2009-01-051-23/+18
| | | | llvm-svn: 61668
* Fix a bug where we'd try to look beyond the current cached tokens whenChris Lattner2009-01-051-2/+2
| | | | | | not in backtracking mode. This was just using the wrong predicate. llvm-svn: 61666
* TryAnnotateTypeOrScopeToken and TryAnnotateCXXScopeToken can Chris Lattner2009-01-051-6/+6
| | | | | | | only be called when they might be needed now, so make them assert that their current token is :: or identifier. llvm-svn: 61662
* ParseCXXSimpleTypeSpecifier can only be called on things that areChris Lattner2009-01-051-15/+24
| | | | | | | | | | | | verified to be simple type specifiers, so there is no need for it to call TryAnnotateTypeOrScopeToken. Make MaybeParseCXXScopeSpecifier reject ::new and ::delete with a hard error now that it may never be transitively called in a context where these are legal. This allows me to start disentangling things more. llvm-svn: 61659
* my previous patch caused sema to drop the global qualifier, makeChris Lattner2009-01-041-11/+23
| | | | | | | sure to pass it down. This makes the code a bit gross, I will clean it up in subsequent commits. llvm-svn: 61650
* eliminate lookahead when parsing ::new / ::delete.Chris Lattner2009-01-041-34/+19
| | | | llvm-svn: 61638
* minor simplifications.Chris Lattner2009-01-041-16/+14
| | | | llvm-svn: 61637
* Convert a big bunch of expression parsers to use smart pointers.Sebastian Redl2008-12-111-51/+51
| | | | llvm-svn: 60906
* Convert some more expression parsers to use smart pointers.Sebastian Redl2008-12-111-1/+1
| | | | llvm-svn: 60904
* Convert selected expression parsers to use smart pointers.Sebastian Redl2008-12-111-13/+13
| | | | llvm-svn: 60900
* Modify the move emulation according to the excellent design of Howard ↵Sebastian Redl2008-12-101-13/+14
| | | | | | 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
* Kick out the proof-of-concept ASTOwner and replace it with ASTOwningResultSebastian Redl2008-12-091-8/+8
| | | | llvm-svn: 60791
* Consistently use smart pointers for stmt and expr nodes in parser local ↵Sebastian Redl2008-12-091-24/+25
| | | | | | variables. llvm-svn: 60761
* fix typo.Zhongxing Xu2008-12-081-1/+1
| | | | llvm-svn: 60686
* Add better comments to ::new parsing. Thanks to Doug for the review.Sebastian Redl2008-12-021-2/+2
| | | | llvm-svn: 60423
* Make the parser handle ::new and ::delete correctly.Sebastian Redl2008-12-021-0/+6
| | | | llvm-svn: 60421
* Handle new by passing the Declaration to the Action, not a processed type.Sebastian Redl2008-12-021-56/+48
| | | | llvm-svn: 60413
* Implement some suggestions by Daniel:Argyrios Kyrtzidis2008-11-261-6/+14
| | | | | | | | -Change Parser::ParseCXXScopeSpecifier to MaybeParseCXXScopeSpecifier -Remove Parser::isTokenCXXScopeSpecifier and fold it into MaybeParseCXXScopeSpecifier -Rename Parser::TryAnnotateScopeToken to TryAnnotateCXXScopeToken and only allow it to be called when in C++ llvm-svn: 60117
* Use RAII objects to ensure proper destruction of expression and statement ↵Sebastian Redl2008-11-251-6/+7
| | | | | | AST nodes in the parser in most cases, even on error. llvm-svn: 60057
* make the 'to match this' diagnostic a note.Chris Lattner2008-11-231-1/+1
| | | | llvm-svn: 59921
* Implementation of new and delete parsing and sema.Sebastian Redl2008-11-211-1/+227
| | | | | | This version uses VLAs to represent arrays. I'll try an alternative way next, but I want this safe first. llvm-svn: 59835
OpenPOWER on IntegriCloud