summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Some tweaks suggested by ArgirisDouglas Gregor2008-11-191-5/+5
| | | | llvm-svn: 59661
* Extend DeclarationName to support C++ overloaded operators, e.g.,Douglas Gregor2008-11-181-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | operator+, directly, using the same mechanism as all other special names. Removed the "special" identifiers for the overloaded operators from the identifier table and IdentifierInfo data structure. IdentifierInfo is back to representing only real identifiers. Added a new Action, ActOnOperatorFunctionIdExpr, that builds an expression from an parsed operator-function-id (e.g., "operator +"). ActOnIdentifierExpr used to do this job, but operator-function-ids are no longer represented by IdentifierInfo's. Extended Declarator to store overloaded operator names. Sema::GetNameForDeclarator now knows how to turn the operator name into a DeclarationName for the overloaded operator. Except for (perhaps) consolidating the functionality of ActOnIdentifier, ActOnOperatorFunctionIdExpr, and ActOnConversionFunctionExpr into a common routine that builds an appropriate DeclRefExpr by looking up a DeclarationName, all of the work on normalizing declaration names should be complete with this commit. llvm-svn: 59526
* Change a couple of the Parser::Diag methods to return DiagnosticInfoChris Lattner2008-11-181-9/+5
| | | | | | | | | 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
* Updated IdentifierResolver to deal with DeclarationNames. The names ofDouglas Gregor2008-11-171-5/+9
| | | | | | | | | | | | | | | | | | | | | C++ constructors, destructors, and conversion functions now have a FETokenInfo field that IdentifierResolver can access, so that these special names are handled just like ordinary identifiers. A few other Sema routines now use DeclarationNames instead of IdentifierInfo*'s. To validate this design, this code also implements parsing and semantic analysis for id-expressions that name conversion functions, e.g., return operator bool(); The new parser action ActOnConversionFunctionExpr takes the result of parsing "operator type-id" and turning it into an expression, using the IdentifierResolver with the DeclarationName of the conversion function. ActOnDeclarator pushes those conversion function names into scope so that the IdentifierResolver can find them, of course. llvm-svn: 59462
* Some cleanups for C++ operator overloadingDouglas Gregor2008-11-171-11/+7
| | | | llvm-svn: 59443
* Implement C++ 'typeid' parsing and sema.Sebastian Redl2008-11-111-0/+48
| | | | llvm-svn: 59042
* Some cleanups to the declaration/checking of overloaded operators in C++. ↵Douglas Gregor2008-11-101-2/+2
| | | | | | Thanks to Sebastian for the review llvm-svn: 58986
OpenPOWER on IntegriCloud