Commit Graph

1025 Commits

Author SHA1 Message Date
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
Chris Lattner 046485640d fix typo
llvm-svn: 53848
2008-07-21 07:13:18 +00:00
Argyrios Kyrtzidis 16c04102ed Add 'this' in the comments of Parser::ParseCastExpression to indicate that it is handled.
llvm-svn: 53665
2008-07-16 07:23:27 +00:00
Ted Kremenek 10c8d7653b Use lowercase of attribute iboutlet to not conflict with the macro IBOutlet
llvm-svn: 53645
2008-07-15 22:38:34 +00:00
Ted Kremenek 8e3704d35a Added parsing/sema support for __attribute__ ((IBOutlet)), a clang-specific attribute that the static analyzer will use to recognize what ivars are IBOutlets.
llvm-svn: 53644
2008-07-15 22:26:48 +00:00
Argyrios Kyrtzidis 07b8b63f9f Use of NextToken() makes ParseIdentifierStatement unnecessary.
Simplify the parser by removing Parser::ParseIdentifierStatement.

llvm-svn: 53520
2008-07-12 21:04:42 +00:00
Argyrios Kyrtzidis 832e898803 Simplify the parser a bit by looking at the next token without consuming it (by Preprocessor::LookNext):
-Remove ParseExpressionWithLeadingIdentifier and ParseAssignmentExprWithLeadingIdentifier.
-Separate ParseLabeledStatement from ParseIdentifierStatement.

llvm-svn: 53376
2008-07-09 22:53:07 +00:00
Argyrios Kyrtzidis ed9834272f Add Sema support for C++ classes.
llvm-svn: 52956
2008-07-01 10:37:29 +00:00
Argyrios Kyrtzidis f4ebe9ea4f Handle unnamed bitfields when parsing C++ classes.
llvm-svn: 52855
2008-06-28 08:10:48 +00:00
Chris Lattner cf31de3760 Make Declarator::getDeclSpec() return a const reference to avoid
cases where mutation can introduce bugs.  Propagate around 'const'.

llvm-svn: 52772
2008-06-26 06:49:43 +00:00
Argyrios Kyrtzidis a781452193 The only caller of this knows that the current token is l_brace, so this can be an assert; suggestion by Chris.
llvm-svn: 52696
2008-06-24 22:31:41 +00:00
Argyrios Kyrtzidis 7bbb20e338 Add parsing support for C++ classes.
Note that Parser::ParseCXXMemberSpecification is temporarily disabled until the Sema support is in place.
Once ParseCXXMemberSpecification is enabled, the Parser/cxx-class.cpp test will pass.

llvm-svn: 52694
2008-06-24 22:12:16 +00:00
Chris Lattner 535b830449 add parser and sema support for the funny ObjC '@defs' thing.
Patch by David Chisnall!

llvm-svn: 52586
2008-06-21 19:39:06 +00:00
Argyrios Kyrtzidis e6aff3db25 K&R-style functions not allowed in C++.
llvm-svn: 52575
2008-06-21 10:00:56 +00:00
Mike Stump 65643c6480 One more test checkin.
Remove an extra space at the end of a line.

llvm-svn: 52504
2008-06-19 19:52:46 +00:00
Mike Stump 01e07653d4 Test commit to see if new account works.
I choose to remove extraneous whitespace at end of lines as a semantic
nop for the test.

llvm-svn: 52503
2008-06-19 19:28:49 +00:00
Nuno Lopes b6f7953818 implement the alias attirbute (in both Sema and Codegen)
llvm-svn: 52092
2008-06-08 15:45:52 +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 cfdf6166fc Support "<p>" as a short-hand for "id<p>". Here's a comment from GCC (the only documentation I could find on it).
/* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>" - nisse@lysator.liu.se.  */

This commit adds the parser magic. The type associated with <p> is still incorrect. Will discuss with Chris.

llvm-svn: 51972
2008-06-05 00:02:44 +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
Chris Lattner fd2fe8270e handle the full assignment-expression grammar when using an
objc message send in an initializer expression.

llvm-svn: 51882
2008-06-02 21:31:07 +00:00
Chris Lattner a120a521a5 Fix a couple crashes on invalid input.
llvm-svn: 51622
2008-05-27 23:32:43 +00:00
Eli Friedman 3e113409cb Implementation of gcc mode attribute; this is significant because
it fixes PR2204.  Not too much to say about the implementation; it works 
in a similar way to the vector size attribute.

At some point, we need to modify the targets to provide information 
about the appropriate types.

llvm-svn: 51577
2008-05-27 03:33:27 +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
Eli Friedman 2460b0c941 Fix the scope of K&R-style argument declarations so that they don't
extend beyond the end of the function.

I'm not completely sure this is the right way to fix this bug, so 
someone familiar with the parser should double-check.

llvm-svn: 51311
2008-05-20 09:10:20 +00:00
Argyrios Kyrtzidis fa8e15bfa5 -Implement proper name lookup for namespaces.
-identifierResolver exposes an iterator interface to get all decls through the scope chain.
-The semantic staff (checking IdentifierNamespace and Doug's checking for shadowed tags were moved out of IdentifierResolver and back into Sema. IdentifierResolver just gives an iterator for all reachable decls of an identifier.

llvm-svn: 50923
2008-05-09 23:39:43 +00:00
Chris Lattner 2fdcddd78d Don't call into objc front-end when not parsing objc code. This avoids
crashes because objc types aren't set up right.

llvm-svn: 50884
2008-05-09 05:28:21 +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
Argyrios Kyrtzidis 2be96ae68b Convert CRLF to LF.
llvm-svn: 50542
2008-05-01 21:44:34 +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
Argyrios Kyrtzidis 8eab584388 Call ExitScope before ActOnFinishNamespaceDef.
This is the same for functions and it's preferable to have the namespace as DeclContext during ActOnPopScope.

llvm-svn: 50322
2008-04-27 14:10:57 +00:00
Argyrios Kyrtzidis 081148986a Parsing of namespaces:
-NamespaceDecl for the AST
-Checks for name clashes between namespaces and tag/normal declarations.

This commit doesn't implement proper name lookup for namespaces.

llvm-svn: 50321
2008-04-27 13:50:30 +00:00
Nuno Lopes 0276933b4b initial support for recognizing __transparent_union__ attributes
comments on the ML will follow

llvm-svn: 50262
2008-04-25 09:32:00 +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
Chris Lattner 14cd1ee95f Two improvements to initializer parsing:
1. If we hit a semantic error, try harder to recover to emit
   diagnostics for later initializer errors (PR2241).
2. Don't leak parsed initializers on an error.

llvm-svn: 49998
2008-04-20 19:07:56 +00:00
Nate Begeman ce4d7fce6b OCUVector -> ExtVector, shorthand for extended vector, per feedback from Chris.
llvm-svn: 49942
2008-04-18 23:10:10 +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
Douglas Gregor 423984d33b Make Parser::getAccessSpecifierIfPresent const, since it does not modify the state
llvm-svn: 49629
2008-04-14 00:13:42 +00:00
Douglas Gregor 556877c1e6 This patch adds very basic support for parsing and type-checking class
inheritance in C++. It'll parse the base-specifier list, e.g.,

 class D : public B1, virtual public B2 { };

and do some of the simpler semantic checks (B1 and B2 are classes;
they aren't unions or incomplete types, etc).

llvm-svn: 49623
2008-04-13 21:30:24 +00:00
Chris Lattner 861a226586 This patch is just the easy part of the class names patch, which
allows the parsing of "class" in addition to "struct" and "union" to
declare a record.  So this patch allows:

 class C { };
 class C c1;

But it does not contain the lookup bits, so this won't work yet:

 C c2;

Patch by Doug Gregor!

llvm-svn: 49613
2008-04-13 18:59:07 +00:00
Chris Lattner b0d3844fb8 Default argument cleanups and minor improvements, patch by
Doug Gregor!

llvm-svn: 49598
2008-04-12 23:52:44 +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 5c7fce453d reduce the amount of 'C++ magic' this code depends on :)
llvm-svn: 49489
2008-04-10 16:37:40 +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 32295d344a Simplify lifetime of location object.
llvm-svn: 49467
2008-04-10 06:15:14 +00:00
Chris Lattner 58258246ec Several improvements from Doug Gregor related to default
argument handling.  I'll fix up the c89 (void) thing next.

llvm-svn: 49459
2008-04-10 02:22:51 +00:00
Chris Lattner aa9c7aed0f Add support for C++ default arguments, and rework Parse-Sema
interaction for function parameters, fixing PR2046.

Patch by Doug Gregor!

llvm-svn: 49369
2008-04-08 04:40:51 +00:00
Steve Naroff fba3942438 Have Parser::FuzzyParseMicrosoftAsmStatement() return the null statement (';').
llvm-svn: 49349
2008-04-07 21:06:54 +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 784903e4c1 move a semantic check out of the parser into sema.
llvm-svn: 49273
2008-04-06 07:49:57 +00:00
Chris Lattner 371ed4e7a9 now that identifier list parsing is split out, simplify handling of
normal typed argument lists.

llvm-svn: 49272
2008-04-06 06:57:35 +00:00
Chris Lattner 285a3e47be reject 'int test(x, x) int x; {}'
llvm-svn: 49271
2008-04-06 06:50:56 +00:00
Chris Lattner 67b450cb48 reject 'typedef int y; int test(x, y)'.
llvm-svn: 49270
2008-04-06 06:47:48 +00:00
Chris Lattner 9186f556cc simplify Parser::ParseFunctionDeclaratorIdentifierList
llvm-svn: 49269
2008-04-06 06:39:19 +00:00
Chris Lattner 6c940e6e6a split parsing of identifier lists in function declarators out into
their own method.

llvm-svn: 49268
2008-04-06 06:34:08 +00:00
Chris Lattner 69740a60b6 minor simplification
llvm-svn: 49267
2008-04-06 06:03:03 +00:00
Chris Lattner 65dd843cb4 finish up throw parsing.
llvm-svn: 49266
2008-04-06 06:02:23 +00:00
Chris Lattner c0a1c7d387 split code for handling grouping parens in declarators from code that
handles function argument parens in declarators.

llvm-svn: 49265
2008-04-06 05:45:57 +00:00
Chris Lattner c439f0de6d another minor simplification
llvm-svn: 49264
2008-04-06 05:27:21 +00:00
Chris Lattner 521ff2b430 Use token lookahead to simplify some code that is rarely executed.
Since it is rare, the cost is not significant and we enjoy the 
simplification.

llvm-svn: 49263
2008-04-06 05:26:30 +00:00
Chris Lattner 9d51f2b9d4 Fix handling of implicit int, resolving PR2012 and reverting (and
subsuming) my patch for PR1999.

llvm-svn: 49251
2008-04-05 06:32:51 +00:00
Chris Lattner 94fc8063b4 Step #1 to fixing PR2012: c89 allows declspecs to be completely
missing from function definitions only.  If we see a function 
definiton with missing declspecs, just fudge in an int.

llvm-svn: 49250
2008-04-05 05:52:15 +00:00
Steve Naroff 2fc93f5c43 Two changes to Sema::LookupDecl() interface.
(1) Remove IdLoc (it's never used). 
(2) Add a bool to enable/disable lazy builtin creaation (defaults to true).

This enables us to use LookupDecl() in Sema::isTypeName(), which is also part of this commit.

To make this work, I changed isTypeName() to be a non-const member function. I'm not happy with this, however I fiddled with making LookupDecl() and friends const and it got ugly pretty quickly. We can certainly add it back if/when someone has time to fiddle with it. For now, I thought this simplification was more important than retaining the const-ness. 

llvm-svn: 49087
2008-04-02 14:35:35 +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