Commit Graph

272 Commits

Author SHA1 Message Date
Sebastian Redl d65cea8dde Convert a big bunch of expression parsers to use smart pointers.
llvm-svn: 60906
2008-12-11 22:51:44 +00:00
Sebastian Redl 90893187c4 Convert some more expression parsers to use smart pointers.
llvm-svn: 60904
2008-12-11 22:33:27 +00:00
Sebastian Redl 59b5e517c7 Convert selected expression parsers to use smart pointers.
llvm-svn: 60900
2008-12-11 21:36:32 +00:00
Sebastian Redl bab9a4b5ea Convert the remaining statement parsers to smart pointers.
llvm-svn: 60895
2008-12-11 20:12:42 +00:00
Sebastian Redl 042ad95d4e Convert a number of statement parsers to smart pointers.
llvm-svn: 60888
2008-12-11 19:30:53 +00:00
Douglas Gregor 7307d6ca96 Use a scoped object to manage entry/exit from a parser scope rather than explicitly calling EnterScope/ExitScope
llvm-svn: 60830
2008-12-10 06:34:36 +00:00
Sebastian Redl d9f7b1c230 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.
llvm-svn: 60809
2008-12-10 00:02:53 +00:00
Sebastian Redl c13f26873f Kick out the proof-of-concept ASTOwner and replace it with ASTOwningResult
llvm-svn: 60791
2008-12-09 20:22:58 +00:00
Sebastian Redl 17f2c7d251 Consistently use smart pointers for stmt and expr nodes in parser local variables.
llvm-svn: 60761
2008-12-09 13:15:23 +00:00
Chris Lattner 3a90716f6a improve comment.
llvm-svn: 60718
2008-12-08 21:53:24 +00:00
Fariborz Jahanian f8ef9f3dc9 Set default property attributes on each property.
Implemented anonymous category (also know as continuation class)
used to override main class's property attribute. This is work in 
propgress.

llvm-svn: 60114
2008-11-26 20:01:34 +00:00
Sebastian Redl 511ed55524 Use RAII objects to ensure proper destruction of expression and statement AST nodes in the parser in most cases, even on error.
llvm-svn: 60057
2008-11-25 22:21:31 +00:00
Chris Lattner 9b5a53424b Daniel really really likes = instead of += :)
llvm-svn: 59716
2008-11-20 07:09:32 +00:00
Chris Lattner 68e486804f Rename IdentifierInfo::isName to ::isStr. Use a nifty trick
from Sebastian to enforce that a literal string is passed in,
and use this to avoid having to call strlen on it.

llvm-svn: 59706
2008-11-20 04:42:34 +00:00
Steve Naroff 9e4ac111f0 Fix <rdar://problem/6150376> [sema] crash on invalid message send.
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
2008-11-19 15:54:23 +00:00
Chris Lattner 406c096993 remove some uses of IdentifierInfo::getName()
llvm-svn: 59606
2008-11-19 07:49:38 +00:00
Chris Lattner 66e3877b42 Use smallstring instead of new[]'ing a string. This simplifies
the code and speeds it up.

llvm-svn: 59604
2008-11-19 07:41:27 +00:00
Chris Lattner ebad6a220f remove uses of IdentifierInfo::getName()
llvm-svn: 59603
2008-11-19 07:37:42 +00:00
Chris Lattner 3d31c6c823 remove the last couple obsolete forms of Parser::Diag.
llvm-svn: 59510
2008-11-18 07:50:21 +00:00
Chris Lattner 6d29c10564 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.

llvm-svn: 59509
2008-11-18 07:48:38 +00:00
Chris Lattner b795443082 some minor cleanups to ParseObjCTypeName:
1. Remove a bogus assertion, clients other than sema can return a
   null pointer from actions that result in ParseTypeName returning null.
2. Remove dead RParenLoc variable.
3. Simplify control flow handling error conditions.
4. On a major failure, we should skip until ')' not until '}'.

llvm-svn: 57949
2008-10-22 03:52:06 +00:00
Steve Naroff 90255b4f54 Fix a crasher during error recovery in Parser::ParseObjCTypeName().
Found this while fixing another unrelated radar.

llvm-svn: 57904
2008-10-21 14:15:04 +00:00
Chris Lattner 2dfde91064 eliminate ObjCPropertyAttrs an corresponding enums, just use
strcmp when needed.

llvm-svn: 57817
2008-10-20 07:43:01 +00:00
Chris Lattner 825bca174d rearrange some code.
llvm-svn: 57816
2008-10-20 07:39:53 +00:00
Chris Lattner 1db3354d89 more simplifications to error recovery in ParseObjCPropertyAttribute
llvm-svn: 57815
2008-10-20 07:37:22 +00:00
Chris Lattner beca77018a move some code around to make it fall through more, no functionality change.
llvm-svn: 57813
2008-10-20 07:24:39 +00:00
Chris Lattner 7661923999 reject properties completely in objc1 instead of emitting
weird errors about property attributes being unknown.

llvm-svn: 57812
2008-10-20 07:22:18 +00:00
Chris Lattner 64b1f2f030 More property attribute recovery improvements. Instead of this:
crash.m:8:12: error: type name requires a specifier or qualifier
@property (readonlyx, getter=isAwesome) int _awesome;
           ^
crash.m:8:29: error: expected ';' at end of declaration list
@property (readonlyx, getter=isAwesome) int _awesome;
                            ^
crash.m:8:39: error: expected identifier or '('
@property (readonlyx, getter=isAwesome) int _awesome;
                                      ^

we now get:

crash.m:8:12: error: unknown property attribute 'readonlyx'
@property (readonlyx, getter=isAwesome) int _awesome;
           ^

Also, we can eliminate isObjCPropertyAttribute now.

llvm-svn: 57811
2008-10-20 07:15:22 +00:00
Chris Lattner 43c76c38fa significantly simplify and clean up error recovery in
ParseObjCPropertyAttribute.  Before, on this code (where
a comma was forgotten):

@property (readonly getter=isAwesome) int _awesome;

we emitted:

crash.m:9:11: error: expected ')'
@property (readonly getter=isAwesome) int _awesome;
          ^
crash.m:9:37: error: type name requires a specifier or qualifier
@property (readonly getter=isAwesome) int _awesome;
                                    ^
crash.m:9:37: error: expected identifier or '('
crash.m:9:37: error: expected ';' at end of declaration list
crash.m:9:1: error: @property requires fields to be named
@property (readonly getter=isAwesome) int _awesome;
^

now we emit:

crash.m:9:21: error: expected ')'
@property (readonly getter=isAwesome) int _awesome;
                    ^
crash.m:9:11: error: to match this '('
@property (readonly getter=isAwesome) int _awesome;
          ^

llvm-svn: 57809
2008-10-20 07:00:43 +00:00
Chris Lattner 93429b047b fix a crash on unnamed properties like:
@property (readonly) int : 4;

llvm-svn: 57805
2008-10-20 06:33:53 +00:00
Chris Lattner e0d3fe9b97 simplify some code by using ExpectAndConsume. When an error
occurs, skip to an @ or ; instead of to a } or ;.  Properties
don't necessarily live in {}'s.

llvm-svn: 57804
2008-10-20 06:15:13 +00:00
Chris Lattner da9fb15b90 refactor a bunch of code:
Check for @end in ParseObjCInterfaceDeclList instead of in each caller
Handle @required and @optional with the same code

Add some fixmes about some apparently objc2 code that is being accepted
in objc1.

llvm-svn: 57803
2008-10-20 06:10:06 +00:00
Chris Lattner bb8cc18788 fix some minor error recovery bugs in ParseObjCInterfaceDeclList
where it would reject @required in non-protocols, but then go
ahead and tag methods with required anyway.  Instead, if we see
this in something other than a protocol, just ignore the request.

Also, improve error recovery a bit when we see something bogus 
inside an interface.

llvm-svn: 57798
2008-10-20 05:57:40 +00:00
Chris Lattner 038a3e349d restructure the body of the ParseObjCInterfaceDeclList loop
to make it easier to understand.  No functionality change.

llvm-svn: 57797
2008-10-20 05:46:22 +00:00
Daniel Dunbar 15619c7e4b Pass postfix attributes to ActOnFields.
llvm-svn: 56992
2008-10-03 02:03:53 +00:00
Ted Kremenek 68d2190226 Enter a new scope for a @try block.
llvm-svn: 56668
2008-09-26 17:32:47 +00:00
Daniel Dunbar 26e2ab4a37 Parser support for prefix __attribute__ on @protocol.
llvm-svn: 56642
2008-09-26 04:48:09 +00:00
Ted Kremenek a34ea3b9cf Have @finally introduce a new scope.
Fixes: <rdar://problem/6248119> @finally doesn't introduce a new scope

llvm-svn: 56629
2008-09-26 00:31:16 +00:00
Chris Lattner a7b034463e Fix rdar://6222856: the receiver of a message expr is an
arbitrary expr, not just a assign expr.  The grammar comment
was right, the code was just wrong.

llvm-svn: 56353
2008-09-19 17:44:00 +00:00
Daniel Dunbar ad3cdc2ba7 Synthesize property setter method as we do for getter.
- Also, fix Parser to construct proper SetterName selector (should be
   lifted out of parser though).

llvm-svn: 55352
2008-08-26 02:32:45 +00:00
Anders Carlsson f93f56a28e Reserved C++ words are valid selectors in Objective-C++
llvm-svn: 55253
2008-08-23 21:00:01 +00:00
Chris Lattner ce90ef51b9 we already have a handle on the 'in' keyword, don't bother getting two.
llvm-svn: 55217
2008-08-23 02:02:23 +00:00
Chris Lattner 2ebb178f8b Fix a FIXME by not creating an invalid AST on erroneous input. Also
make diagnostic output in some other malformed cases significantly
more useful.  This fixes PR2708

llvm-svn: 55215
2008-08-23 01:48:03 +00:00
Daniel Dunbar 1ff1d1fd51 Move AsmLabel into Declarator instead of just a parameter to
ActOnDeclarator.

llvm-svn: 54353
2008-08-05 16:28:08 +00:00
Chris Lattner 197a301669 Fix rdar://6124613 a crash on invalid code.
llvm-svn: 54340
2008-08-05 06:19:09 +00:00
Daniel Dunbar 4983df37a7 Add more Parser/Sema support for GCC asm-label extension.
- ActOnDeclarator now takes an additional parameter which is the
   AsmLabel if used. Its unfortunate that this bubbles up this high,
   but we cannot just lump it in as an attribute without mistakenly
   *accepting* it as an attribute.
 - The actual asm-label itself is, however, encoded as an AsmLabelAttr
   on the FunctionDecl.
 - Slightly improved parser error recovery on malformed asm-labels.
 - CodeGen support still missing...

llvm-svn: 54339
2008-08-05 01:35:17 +00:00
Chris Lattner df59f5aa3c Pull protocol resolution of out ActOnStartClassInterface, this is also the
last client of the old ParseObjCProtocolReferences, so it also removes it.

llvm-svn: 54094
2008-07-26 04:13:19 +00:00
Chris Lattner b1f3c948ee refactor protocol resolution out of ActOnStartCategoryInterface
llvm-svn: 54093
2008-07-26 04:07:02 +00:00
Chris Lattner 3bbae00f50 pull protocol resolution out into ActOnStartProtocolInterface.
This temporarily duplicates ParseObjCProtocolReferences, but it
will be removed in the future.

llvm-svn: 54092
2008-07-26 04:03:38 +00:00
Chris Lattner e08e47ab2f gcc requires a semicolon at the end of an interface, unlike its extension for structs.
rdar://6095245.

llvm-svn: 54044
2008-07-25 19:54:55 +00:00
Steve Naroff 542cd5d3f9 Move fix in r54013 from the parser to sema.
llvm-svn: 54032
2008-07-25 17:57:26 +00:00
Steve Naroff ce5206b4f2 Fix Parser::ParseObjCMethodDefinition(). Only call the actions module for valid MDecl's.
llvm-svn: 54013
2008-07-25 14:30:25 +00:00
Chris Lattner d7352d6801 minor cleanup to the actions interface to pass around SmallVectorImpl instead
of a specific smallvector size.

Fix protocol lists to pass down proper location info, so we get diagnostics
like this:

t.m:3:35: error: cannot find protocol definition for 'NSCopying', referenced by 'NSWhatever'
@interface NSWhatever : NSObject <NSCopying>
                                  ^

instead of this:

t.m:3:44: error: cannot find protocol definition for 'NSCopying', referenced by 'NSWhatever'
@interface NSWhatever : NSObject <NSCopying>
                                           ^


Add a new IdentifierLocPair typedef which is just a pair<IdentifierInfo*, SourceLocation>

llvm-svn: 53883
2008-07-21 22:17:28 +00:00
Ted Kremenek 09a0d04ea0 Initial work on additional memory collection for ObjC AST objects. We now
have Destroy methods of ObjcMethodDecl and ObjCInterfaceDecl which recursively
destroy their owned Decls and Stmts.  There are a few cases where it is not
clear what to do (FIXMEs included in the patch).

llvm-svn: 52050
2008-06-06 16:45:15 +00:00
Steve Naroff d9c2607014 Parser::ParseObjCSynchronizedStmt() needs to Enter/Exit a decl scope.
llvm-svn: 51963
2008-06-04 20:36:13 +00:00
Steve Naroff b877e2c3ca Fix parser bug/FIXME with @catch.
<rdar://problem/5980846> clang on xcode: error: declarator requires an identifier (for @catch)

llvm-svn: 51895
2008-06-03 05:36:54 +00:00
Steve Naroff 4c290c7c0b Make sure the source location for @property points the the @-sign (not the decl spec).
Also added a FIXME related to how we represent @properties in the ObjCInterfaceDecl AST.

llvm-svn: 51450
2008-05-22 23:24:08 +00:00
Fariborz Jahanian ec6e4c8096 This patch introduces declaration of getter methods for ObjC2's
properties. Couple of property tests will fail with this patch.
Will fix them next.

llvm-svn: 50818
2008-05-07 17:43:59 +00:00
Fariborz Jahanian 09367d68ff Patch to refactor setter/getter names of property attributes into Selector
(was IdentifierInfo * before). This will make method declartations whole
lot easier.

llvm-svn: 50747
2008-05-06 18:09:04 +00:00
Fariborz Jahanian 8d91686b0d percolate @optional/@required protocols down to ASTs for
properties declared in the protocol.

llvm-svn: 50662
2008-05-05 18:51:55 +00:00
Fariborz Jahanian 2dfcec129f Default visbility for instance variables is protected.
Patch by Emerson Murhpy-Hill.

llvm-svn: 50452
2008-04-29 23:03:51 +00:00
Fariborz Jahanian f2a7d7c949 Support for @dynamic AST build.
More property semantics checking.
First test case for ObjC2's property implementation.

llvm-svn: 50057
2008-04-21 21:05:54 +00:00
Fariborz Jahanian ffe97a3925 Initial work for property implementation declarations.
Mostly semantic checking in this patch. This is on going
and incomplete.

llvm-svn: 49882
2008-04-18 00:19:30 +00:00
Fariborz Jahanian 0152a1a5db New AST representation for each objc2's property declaration.
llvm-svn: 49699
2008-04-14 23:36:35 +00:00
Fariborz Jahanian 4572b45574 AST generation for objc2's property declarations.
llvm-svn: 49565
2008-04-11 23:40:25 +00:00
Fariborz Jahanian 963767476c Minor changes per Chris L's review.
llvm-svn: 49539
2008-04-11 16:55:42 +00:00
Fariborz Jahanian de615836f3 Patch for:
1) objc ivar processing is split out of ActOnField into its own ActOnIvar method.
2) the new objc ivar action takes visibility info directly, eliminating 
  AllVisibilities in ParseObjCClassInstanceVariables.

llvm-svn: 49506
2008-04-10 23:32:45 +00:00
Chris Lattner a12405b0ef refactor Parser::ParseStructDeclaration to return a vector of uninterpreted
declarators.  This allows the clients (C structs, objc classes, objc 
properties, [future] C++ classes) etc, to do custom processing before invoking
an action.

This has two benefits in the short term:
1) objc ivar processing should be split out of ActOnField into its own ActOn method.
2) the new objc ivar action can take visibility info directly, eliminating 
   AllVisibilities in ParseObjCClassInstanceVariables.
3) objc properties can pass their own special sauce down to sema as well.

llvm-svn: 49468
2008-04-10 06:46:29 +00:00
Chris Lattner e0ea37ace7 move sorting of qualifying protocols from the parser into
sema.  This allows clients of the parser to have the unmolested 
list if desired, and guarantees that noone can create an
ObjCQualifiedInterfaceType with an unsorted list.

llvm-svn: 49310
2008-04-07 04:56:42 +00:00
Chris Lattner ed0e16404c clean up property memory allocation to move it into the ast classes
like the rest of the classes.

llvm-svn: 48434
2008-03-17 01:19:02 +00:00
Chris Lattner acc04a9261 minor cleanups, make getNumInstanceMethods always return unsigned.
llvm-svn: 48423
2008-03-16 20:19:15 +00:00
Chris Lattner 7a51313d8a 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.

llvm-svn: 48402
2008-03-15 23:59:48 +00:00