summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Disambiguation of '[[':Richard Smith2012-04-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * In C++11, '[[' is ill-formed unless it starts an attribute-specifier. Reject array sizes and array indexes which begin with a lambda-expression. Recover by parsing the lambda as a lambda. * In Objective-C++11, either '[' could be the start of a message-send. Fully disambiguate this case: it turns out that the grammars of message-sends, lambdas and attributes do not actually overlap. Accept any occurrence of '[[' where either '[' starts a message send, but reject a lambda in an array index just like in C++11 mode. Implement a couple of changes to the attribute wording which occurred after our attributes implementation landed: * In a function-declaration, the attributes go after the exception specification, not after the right paren. * A reference type can have attributes applied. * An 'identifier' in an attribute can also be a keyword. Support for alternative tokens (iso646 keywords) in attributes to follow. And some bug fixes: * Parse attributes after declarator-ids, even if they are not simple identifiers. * Do not accept attributes after a parenthesized declarator. * Accept attributes after an array size in a new-type-id. * Partially disamiguate 'delete' followed by a lambda. More work is required here for the case where the lambda-introducer is '[]'. llvm-svn: 154369
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-6/+6
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* De-nest tentative parsing to disambiguate lambdas from designators; noDouglas Gregor2012-02-171-42/+45
| | | | | | functionality change. llvm-svn: 150817
* Disambiguate between C++11 lambda expressions and C99 arrayDouglas Gregor2012-02-171-9/+80
| | | | | | | | | designators in the parser. In the worst case, this disambiguation requires tentative parsing just past the closing ']', but for most cases we'll be able to tell by looking ahead just one token (without going into the heavyweight tentative parsing machinery). llvm-svn: 150790
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Implement the Microsoft __if_exists/if_not_exists extension in initializer-list.Francois Pichet2011-12-121-0/+74
| | | | | | | | | | | | | | | Necessary to parse Microsoft ATL code. Example: int array[] = { 0, __if_exists(CLASS::Type) {2, } 3 }; will declare an array of 2 or 3 elements depending on if CLASS::Type exists or not. llvm-svn: 146447
* Introduce BalancedDelimiterTracker, to better track open/closeDouglas Gregor2011-10-121-8/+15
| | | | | | | delimiter pairs and detect when we exceed the implementation limit for nesting depth, from Aaron Ballman! llvm-svn: 141782
* Improve caret location for the GNU old-style field designator warning, from ↵Douglas Gregor2011-08-271-1/+1
| | | | | | David Blaikie llvm-svn: 138684
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* Implement support for pack expansions in initializer lists andDouglas Gregor2011-01-031-2/+5
| | | | | | expression lists. llvm-svn: 122764
* Implement bracket insertion for Objective-C instance message sends asDouglas Gregor2010-09-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | 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
* One who seeks knowledge learns something new every day.John McCall2010-08-261-6/+6
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-6/+6
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Abstract out passing around types and kill off ActionBase.John McCall2010-08-241-5/+7
| | | | llvm-svn: 111901
* Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).John McCall2010-08-231-5/+5
| | | | llvm-svn: 111863
* Sundry incremental steps towards killing off Action.John McCall2010-08-231-4/+4
| | | | llvm-svn: 111795
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-2/+2
| | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. llvm-svn: 111667
* Move the "current scope" state from the Parser into Action. ThisDouglas Gregor2010-07-021-2/+2
| | | | | | | | | | | | | | allows Sema some limited access to the current scope, which we only use in one way: when Sema is performing some kind of declaration that is not directly driven by the parser (e.g., due to template instantiatio or lazy declaration of a member), we can find the Scope associated with a DeclContext, if that DeclContext is still in the process of being parsed. Use this to make the implicit declaration of special member functions in a C++ class more "scope-less", rather than using the NULL Scope hack. llvm-svn: 107491
* Implement parsing for message sends in Objective-C++. Message sends inDouglas Gregor2010-04-211-28/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Objective-C++ have a more complex grammar than in Objective-C (surprise!), because (1) The receiver of an instance message can be a qualified name such as ::I or identity<I>::type. (2) Expressions in C++ can start with a type. The receiver grammar isn't actually ambiguous; it just takes a bit of work to parse past the type before deciding whether we have a type or expression. We do this in two places within the grammar: once for message sends and once when we're determining whether a []'d clause in an initializer list is a message send or a C99 designated initializer. This implementation of Objective-C++ message sends contains one known extension beyond GCC's implementation, which is to permit a typename-specifier as the receiver type for a class message, e.g., [typename compute_receiver_type<T>::type method]; Note that the same effect can be achieved in GCC by way of a typedef, e.g., typedef typename computed_receiver_type<T>::type Computed; [Computed method]; so this is merely a convenience. Note also that message sends still cannot involve dependent types or values. llvm-svn: 102031
* Migrate the responsibility for turning the receiver name in anDouglas Gregor2010-04-211-25/+7
| | | | | | | | | Objective-C class message expression into a type from the parser (which was doing so in two places) to Action::getObjCMessageKind() which, in the case of Sema, reduces the number of name lookups we need to perform. llvm-svn: 102026
* Rework the Parser-Sema interaction for Objective-C messageDouglas Gregor2010-04-211-7/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sends. Major changes include: - Expanded the interface from two actions (ActOnInstanceMessage, ActOnClassMessage), where ActOnClassMessage also handled sends to "super" by checking whether the identifier was "super", to three actions (ActOnInstanceMessage, ActOnClassMessage, ActOnSuperMessage). Code completion has the same changes. - The parser now resolves the type to which we are sending a class message, so ActOnClassMessage now accepts a TypeTy* (rather than an IdentifierInfo *). This opens the door to more interesting types (for Objective-C++ support). - Split ActOnInstanceMessage and ActOnClassMessage into parser action functions (with their original names) and semantic functions (BuildInstanceMessage and BuildClassMessage, respectively). At present, this split is onyl used by ActOnSuperMessage, which decides which kind of super message it has and forwards to the appropriate Build*Message. In the future, Build*Message will be used by template instantiation. - Use getObjCMessageKind() within the disambiguation of Objective-C message sends vs. array designators. Two notes about substandard bits in this patch: - There is some redundancy in the code in ParseObjCMessageExpr and ParseInitializerWithPotentialDesignator; this will be addressed shortly by centralizing the mapping from identifiers to type names for the message receiver. - There is some #if 0'd code that won't likely ever be used---it handles the use of 'super' in methods whose class does not have a superclass---but could be used to model GCC's behavior more closely. This code will die in my next check-in, but I want it in Subversion. llvm-svn: 102021
* fix a bug I noticed by inspection, correcting two reject-valid bugs.Chris Lattner2010-04-121-3/+8
| | | | llvm-svn: 101026
* fix PR6811 by not parsing 'super' as a magic expression inChris Lattner2010-04-111-17/+21
| | | | | | | | | | | | | LookupInObjCMethod. Doing so allows all sorts of invalid code to slip through to codegen. This patch does not change the AST representation of super, though that would now be a natural thing to do since it can only be in the receiver position and in the base of a ObjCPropertyRefExpr. There are still several ugly areas handling super in the parser, but this is definitely a step in the right direction. llvm-svn: 100959
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-4/+3
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-3/+4
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-4/+3
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* PR5218: Replace IdentifierInfo::getName with StringRef version, now that clientsDaniel Dunbar2009-10-181-1/+1
| | | | | | are updated. llvm-svn: 84447
* Avoid std::string concatenation.Daniel Dunbar2009-10-171-4/+5
| | | | llvm-svn: 84378
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-20/+20
| | | | llvm-svn: 81346
* 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
* Introduce a "-fixit" mode to clang-cc that applies code-modification hints.Douglas Gregor2009-04-021-1/+1
| | | | llvm-svn: 68268
* Make our diagnostics about the obsolete GNU designated-initializerDouglas Gregor2009-03-281-4/+13
| | | | | | | syntax into extension warnings, and provide code-modification hints showing how to fix the problem. llvm-svn: 67885
* Fix <rdar://problem/6724396>, where we were silently droppingDouglas Gregor2009-03-271-1/+2
| | | | | | GNU-style array designators, causing us to emit broken initializers. llvm-svn: 67878
* InitListDesignations hasn't been used (ever). Eliminate it, andDouglas Gregor2009-03-201-60/+32
| | | | | | | simplify the parsing and action interface for designated initializers. llvm-svn: 67415
* Put the invalid flag of OwningResult into the Action pointer.Sebastian Redl2009-02-051-1/+1
| | | | | | | | 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
* Implement and test aggregate initialization in C++. Major changes:Douglas Gregor2009-01-301-3/+3
| | | | | | | | | | | | | | | | - Support initialization of reference members; complain if any reference members are left uninitialized. - Use C++ copy-initialization for initializing each element (falls back to constraint checking in C) - Make sure we diagnose when one tries to provide an initializer list for a non-aggregate. - Don't complain about empty initializers in C++ (they are permitted) - Unrelated but necessary: don't bother trying to convert the decl-specifier-seq to a type when we're dealing with a C++ constructor, destructor, or conversion operator; it results in spurious warnings. llvm-svn: 63431
* 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
* Initial implementation of semantic analysis and ASTs for C99Douglas Gregor2009-01-221-14/+22
| | | | | | | | | | | | | | | | | | designated initializers. This implementation should cover all of the constraints in C99 6.7.8, including long, complex designations and computing the size of incomplete array types initialized with a designated initializer. Please see the new test-case and holler if you find cases where this doesn't work. There are still some wrinkles with GNU's anonymous structs and anonymous unions (it isn't clear how these should work; we'll just follow GCC's lead) and with designated initializers for the members of a union. I'll tackle those very soon. CodeGen is still nonexistent, and there's some leftover code in the parser's representation of designators that I'll also need to clean up. llvm-svn: 62737
* Convert more expression actions to smart pointers.Sebastian Redl2009-01-191-5/+4
| | | | llvm-svn: 62537
* Rename move_convert to move_arg and move_res. The new names are less ↵Sebastian Redl2009-01-181-1/+1
| | | | | | misleading (and shorter). llvm-svn: 62466
* Convert remaining expression parsers to smart pointers. Now on to the Action ↵Sebastian Redl2008-12-131-7/+7
| | | | | | connection. llvm-svn: 60982
* Convert a big bunch of expression parsers to use smart pointers.Sebastian Redl2008-12-111-27/+28
| | | | llvm-svn: 60906
* Convert selected expression parsers to use smart pointers.Sebastian Redl2008-12-111-3/+3
| | | | llvm-svn: 60900
* Modify the move emulation according to the excellent design of Howard ↵Sebastian Redl2008-12-101-6/+7
| | | | | | 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-3/+3
| | | | llvm-svn: 60791
* Consistently use smart pointers for stmt and expr nodes in parser local ↵Sebastian Redl2008-12-091-16/+15
| | | | | | variables. llvm-svn: 60761
* Use RAII objects to ensure proper destruction of expression and statement ↵Sebastian Redl2008-11-251-8/+8
| | | | | | AST nodes in the parser in most cases, even on error. llvm-svn: 60057
* Fix <rdar://problem/6150376> [sema] crash on invalid message send.Steve Naroff2008-11-191-3/+6
| | | | | | The core fix in Sema::ActOnClassMessage(). All the other changes have to do with passing down the SourceLocation for the receiver (to properly position the cursor when producing an error diagnostic). llvm-svn: 59639
* Fix PR3001: if we have an error parsing an initializer, make sure to removeChris Lattner2008-11-031-2/+10
| | | | | | | the designator corresponding to it, otherwise Sema and later parsing will get confused. llvm-svn: 58603
OpenPOWER on IntegriCloud