blob: 0ae11b7e4607f1f0b6c1b34310aa5f8782f4e2cf [file] [log] [blame]
Chris Lattner4b009652007-07-25 00:24:17 +00001//===--- ParseObjc.cpp - Objective C Parsing ------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Steve Naroff and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Objective-C portions of the Parser interface.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Parse/Parser.h"
Steve Naroff09a0c4c2007-08-22 18:35:33 +000015#include "clang/Parse/DeclSpec.h"
Chris Lattner4b009652007-07-25 00:24:17 +000016#include "clang/Basic/Diagnostic.h"
17#include "llvm/ADT/SmallVector.h"
18using namespace clang;
19
20
21/// ParseExternalDeclaration:
22/// external-declaration: [C99 6.9]
23/// [OBJC] objc-class-definition
24/// [OBJC] objc-class-declaration [TODO]
25/// [OBJC] objc-alias-declaration [TODO]
26/// [OBJC] objc-protocol-definition [TODO]
27/// [OBJC] objc-method-definition [TODO]
28/// [OBJC] '@' 'end' [TODO]
Steve Narofffb367882007-08-20 21:31:48 +000029Parser::DeclTy *Parser::ParseObjCAtDirectives() {
Chris Lattner4b009652007-07-25 00:24:17 +000030 SourceLocation AtLoc = ConsumeToken(); // the "@"
31
Steve Naroff87c329f2007-08-23 18:16:40 +000032 switch (Tok.getObjCKeywordID()) {
Chris Lattner4b009652007-07-25 00:24:17 +000033 case tok::objc_class:
34 return ParseObjCAtClassDeclaration(AtLoc);
35 case tok::objc_interface:
Steve Narofffb367882007-08-20 21:31:48 +000036 return ParseObjCAtInterfaceDeclaration(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000037 case tok::objc_protocol:
Steve Naroff72f17fb2007-08-22 22:17:26 +000038 return ParseObjCAtProtocolDeclaration(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000039 case tok::objc_implementation:
Steve Naroff81f1bba2007-09-06 21:24:23 +000040 return ObjcImpDecl = ParseObjCAtImplementationDeclaration(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000041 case tok::objc_end:
Fariborz Jahanian027c23b2007-09-01 00:26:16 +000042 return ParseObjCAtEndDeclaration(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000043 case tok::objc_compatibility_alias:
Fariborz Jahanianb62aff32007-09-04 19:26:51 +000044 return ParseObjCAtAliasDeclaration(AtLoc);
Fariborz Jahanian027c23b2007-09-01 00:26:16 +000045 case tok::objc_synthesize:
46 return ParseObjCPropertySynthesize(AtLoc);
47 case tok::objc_dynamic:
48 return ParseObjCPropertyDynamic(AtLoc);
Chris Lattner4b009652007-07-25 00:24:17 +000049 default:
50 Diag(AtLoc, diag::err_unexpected_at);
51 SkipUntil(tok::semi);
Steve Narofffb367882007-08-20 21:31:48 +000052 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +000053 }
54}
55
56///
57/// objc-class-declaration:
58/// '@' 'class' identifier-list ';'
59///
Steve Narofffb367882007-08-20 21:31:48 +000060Parser::DeclTy *Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
Chris Lattner4b009652007-07-25 00:24:17 +000061 ConsumeToken(); // the identifier "class"
62 llvm::SmallVector<IdentifierInfo *, 8> ClassNames;
63
64 while (1) {
65 if (Tok.getKind() != tok::identifier) {
66 Diag(Tok, diag::err_expected_ident);
67 SkipUntil(tok::semi);
Steve Narofffb367882007-08-20 21:31:48 +000068 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +000069 }
Chris Lattner4b009652007-07-25 00:24:17 +000070 ClassNames.push_back(Tok.getIdentifierInfo());
71 ConsumeToken();
72
73 if (Tok.getKind() != tok::comma)
74 break;
75
76 ConsumeToken();
77 }
78
79 // Consume the ';'.
80 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@class"))
Steve Narofffb367882007-08-20 21:31:48 +000081 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +000082
Steve Naroffb4dfe362007-10-02 22:39:18 +000083 return Actions.ActOnForwardClassDeclaration(CurScope, atLoc,
Steve Naroff81f1bba2007-09-06 21:24:23 +000084 &ClassNames[0], ClassNames.size());
Chris Lattner4b009652007-07-25 00:24:17 +000085}
86
Steve Narofffb367882007-08-20 21:31:48 +000087///
88/// objc-interface:
89/// objc-class-interface-attributes[opt] objc-class-interface
90/// objc-category-interface
91///
92/// objc-class-interface:
93/// '@' 'interface' identifier objc-superclass[opt]
94/// objc-protocol-refs[opt]
95/// objc-class-instance-variables[opt]
96/// objc-interface-decl-list
97/// @end
98///
99/// objc-category-interface:
100/// '@' 'interface' identifier '(' identifier[opt] ')'
101/// objc-protocol-refs[opt]
102/// objc-interface-decl-list
103/// @end
104///
105/// objc-superclass:
106/// ':' identifier
107///
108/// objc-class-interface-attributes:
109/// __attribute__((visibility("default")))
110/// __attribute__((visibility("hidden")))
111/// __attribute__((deprecated))
112/// __attribute__((unavailable))
113/// __attribute__((objc_exception)) - used by NSException on 64-bit
114///
115Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration(
116 SourceLocation atLoc, AttributeList *attrList) {
Steve Naroff87c329f2007-08-23 18:16:40 +0000117 assert(Tok.isObjCAtKeyword(tok::objc_interface) &&
Steve Narofffb367882007-08-20 21:31:48 +0000118 "ParseObjCAtInterfaceDeclaration(): Expected @interface");
119 ConsumeToken(); // the "interface" identifier
120
121 if (Tok.getKind() != tok::identifier) {
122 Diag(Tok, diag::err_expected_ident); // missing class or category name.
123 return 0;
124 }
125 // We have a class or category name - consume it.
Steve Naroff72f17fb2007-08-22 22:17:26 +0000126 IdentifierInfo *nameId = Tok.getIdentifierInfo();
Steve Narofffb367882007-08-20 21:31:48 +0000127 SourceLocation nameLoc = ConsumeToken();
128
Steve Naroffa7f62782007-08-23 19:56:30 +0000129 if (Tok.getKind() == tok::l_paren) { // we have a category.
Steve Narofffb367882007-08-20 21:31:48 +0000130 SourceLocation lparenLoc = ConsumeParen();
131 SourceLocation categoryLoc, rparenLoc;
132 IdentifierInfo *categoryId = 0;
Fariborz Jahanianf25220e2007-09-18 20:26:58 +0000133 llvm::SmallVector<IdentifierInfo *, 8> ProtocolRefs;
Steve Narofffb367882007-08-20 21:31:48 +0000134
Steve Naroffa7f62782007-08-23 19:56:30 +0000135 // For ObjC2, the category name is optional (not an error).
Steve Narofffb367882007-08-20 21:31:48 +0000136 if (Tok.getKind() == tok::identifier) {
137 categoryId = Tok.getIdentifierInfo();
138 categoryLoc = ConsumeToken();
Steve Naroffa7f62782007-08-23 19:56:30 +0000139 } else if (!getLang().ObjC2) {
140 Diag(Tok, diag::err_expected_ident); // missing category name.
141 return 0;
Steve Narofffb367882007-08-20 21:31:48 +0000142 }
143 if (Tok.getKind() != tok::r_paren) {
144 Diag(Tok, diag::err_expected_rparen);
145 SkipUntil(tok::r_paren, false); // don't stop at ';'
146 return 0;
147 }
148 rparenLoc = ConsumeParen();
149 // Next, we need to check for any protocol references.
150 if (Tok.getKind() == tok::less) {
Steve Naroff304ed392007-09-05 23:30:30 +0000151 if (ParseObjCProtocolReferences(ProtocolRefs))
Steve Narofffb367882007-08-20 21:31:48 +0000152 return 0;
153 }
154 if (attrList) // categories don't support attributes.
155 Diag(Tok, diag::err_objc_no_attributes_on_category);
156
Steve Naroff25aace82007-10-03 21:00:46 +0000157 DeclTy *CategoryType = Actions.ActOnStartCategoryInterface(CurScope, atLoc,
158 nameId, nameLoc, categoryId, categoryLoc,
159 &ProtocolRefs[0], ProtocolRefs.size());
Fariborz Jahanianf25220e2007-09-18 20:26:58 +0000160
161 ParseObjCInterfaceDeclList(CategoryType, tok::objc_not_keyword);
Steve Narofffb367882007-08-20 21:31:48 +0000162
Steve Naroff0bbffd82007-08-22 16:35:03 +0000163 // The @ sign was already consumed by ParseObjCInterfaceDeclList().
Steve Naroff87c329f2007-08-23 18:16:40 +0000164 if (Tok.isObjCAtKeyword(tok::objc_end)) {
Steve Naroff0bbffd82007-08-22 16:35:03 +0000165 ConsumeToken(); // the "end" identifier
Steve Narofffb367882007-08-20 21:31:48 +0000166 return 0;
167 }
Steve Naroff0bbffd82007-08-22 16:35:03 +0000168 Diag(Tok, diag::err_objc_missing_end);
Steve Narofffb367882007-08-20 21:31:48 +0000169 return 0;
170 }
171 // Parse a class interface.
172 IdentifierInfo *superClassId = 0;
173 SourceLocation superClassLoc;
Steve Naroff72f17fb2007-08-22 22:17:26 +0000174
Steve Narofffb367882007-08-20 21:31:48 +0000175 if (Tok.getKind() == tok::colon) { // a super class is specified.
176 ConsumeToken();
177 if (Tok.getKind() != tok::identifier) {
178 Diag(Tok, diag::err_expected_ident); // missing super class name.
179 return 0;
180 }
181 superClassId = Tok.getIdentifierInfo();
182 superClassLoc = ConsumeToken();
183 }
184 // Next, we need to check for any protocol references.
Steve Naroff304ed392007-09-05 23:30:30 +0000185 llvm::SmallVector<IdentifierInfo *, 8> ProtocolRefs;
Steve Narofffb367882007-08-20 21:31:48 +0000186 if (Tok.getKind() == tok::less) {
Steve Naroff304ed392007-09-05 23:30:30 +0000187 if (ParseObjCProtocolReferences(ProtocolRefs))
Steve Narofffb367882007-08-20 21:31:48 +0000188 return 0;
189 }
Steve Naroff25aace82007-10-03 21:00:46 +0000190 DeclTy *ClsType = Actions.ActOnStartClassInterface(CurScope,
Fariborz Jahanianc091b5d2007-09-25 18:38:09 +0000191 atLoc, nameId, nameLoc,
Steve Naroff304ed392007-09-05 23:30:30 +0000192 superClassId, superClassLoc, &ProtocolRefs[0],
193 ProtocolRefs.size(), attrList);
194
Steve Narofffb367882007-08-20 21:31:48 +0000195 if (Tok.getKind() == tok::l_brace)
Steve Naroff81f1bba2007-09-06 21:24:23 +0000196 ParseObjCClassInstanceVariables(ClsType);
Steve Narofffb367882007-08-20 21:31:48 +0000197
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +0000198 ParseObjCInterfaceDeclList(ClsType, tok::objc_interface);
Steve Naroff0bbffd82007-08-22 16:35:03 +0000199
200 // The @ sign was already consumed by ParseObjCInterfaceDeclList().
Steve Naroff87c329f2007-08-23 18:16:40 +0000201 if (Tok.isObjCAtKeyword(tok::objc_end)) {
Steve Naroff0bbffd82007-08-22 16:35:03 +0000202 ConsumeToken(); // the "end" identifier
Steve Narofffaed3bf2007-09-10 20:51:04 +0000203 return ClsType;
Steve Narofffb367882007-08-20 21:31:48 +0000204 }
Steve Naroff0bbffd82007-08-22 16:35:03 +0000205 Diag(Tok, diag::err_objc_missing_end);
Steve Narofffb367882007-08-20 21:31:48 +0000206 return 0;
207}
208
209/// objc-interface-decl-list:
210/// empty
Steve Narofffb367882007-08-20 21:31:48 +0000211/// objc-interface-decl-list objc-property-decl [OBJC2]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000212/// objc-interface-decl-list objc-method-requirement [OBJC2]
Steve Naroff81f1bba2007-09-06 21:24:23 +0000213/// objc-interface-decl-list objc-method-proto ';'
Steve Narofffb367882007-08-20 21:31:48 +0000214/// objc-interface-decl-list declaration
215/// objc-interface-decl-list ';'
216///
Steve Naroff0bbffd82007-08-22 16:35:03 +0000217/// objc-method-requirement: [OBJC2]
218/// @required
219/// @optional
220///
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +0000221void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl,
222 tok::ObjCKeywordKind contextKey) {
Fariborz Jahanian3dc7cbc2007-09-10 20:33:04 +0000223 llvm::SmallVector<DeclTy*, 32> allMethods;
Fariborz Jahanian8b5ab6f2007-09-18 00:25:23 +0000224 tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword;
Steve Naroff0bbffd82007-08-22 16:35:03 +0000225 while (1) {
226 if (Tok.getKind() == tok::at) {
227 SourceLocation AtLoc = ConsumeToken(); // the "@"
Steve Naroff87c329f2007-08-23 18:16:40 +0000228 tok::ObjCKeywordKind ocKind = Tok.getObjCKeywordID();
Steve Naroff0bbffd82007-08-22 16:35:03 +0000229
230 if (ocKind == tok::objc_end) { // terminate list
Fariborz Jahanian3dc7cbc2007-09-10 20:33:04 +0000231 break;
Steve Naroff0bbffd82007-08-22 16:35:03 +0000232 } else if (ocKind == tok::objc_required) { // protocols only
233 ConsumeToken();
Fariborz Jahanian8b5ab6f2007-09-18 00:25:23 +0000234 MethodImplKind = ocKind;
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +0000235 if (contextKey != tok::objc_protocol)
236 Diag(AtLoc, diag::err_objc_protocol_required);
Steve Naroff0bbffd82007-08-22 16:35:03 +0000237 } else if (ocKind == tok::objc_optional) { // protocols only
238 ConsumeToken();
Fariborz Jahanian8b5ab6f2007-09-18 00:25:23 +0000239 MethodImplKind = ocKind;
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +0000240 if (contextKey != tok::objc_protocol)
241 Diag(AtLoc, diag::err_objc_protocol_optional);
Steve Naroff0bbffd82007-08-22 16:35:03 +0000242 } else if (ocKind == tok::objc_property) {
Fariborz Jahanian86f74a42007-09-12 18:23:47 +0000243 ParseObjCPropertyDecl(interfaceDecl);
Steve Naroff0bbffd82007-08-22 16:35:03 +0000244 continue;
245 } else {
246 Diag(Tok, diag::err_objc_illegal_interface_qual);
247 ConsumeToken();
248 }
249 }
250 if (Tok.getKind() == tok::minus || Tok.getKind() == tok::plus) {
Fariborz Jahanian8b5ab6f2007-09-18 00:25:23 +0000251 DeclTy *methodPrototype = ParseObjCMethodPrototype(interfaceDecl, MethodImplKind);
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +0000252 allMethods.push_back(methodPrototype);
Steve Naroff81f1bba2007-09-06 21:24:23 +0000253 // Consume the ';' here, since ParseObjCMethodPrototype() is re-used for
254 // method definitions.
Steve Naroffaa1b6d42007-09-17 15:07:43 +0000255 ExpectAndConsume(tok::semi, diag::err_expected_semi_after,"method proto");
Steve Naroff0bbffd82007-08-22 16:35:03 +0000256 continue;
257 }
258 if (Tok.getKind() == tok::semi)
259 ConsumeToken();
260 else if (Tok.getKind() == tok::eof)
Fariborz Jahanian3dc7cbc2007-09-10 20:33:04 +0000261 break;
Steve Naroff304ed392007-09-05 23:30:30 +0000262 else {
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000263 // FIXME: as the name implies, this rule allows function definitions.
264 // We could pass a flag or check for functions during semantic analysis.
Steve Naroff81f1bba2007-09-06 21:24:23 +0000265 ParseDeclarationOrFunctionDefinition();
Steve Naroff304ed392007-09-05 23:30:30 +0000266 }
Steve Naroff0bbffd82007-08-22 16:35:03 +0000267 }
Fariborz Jahanian3dc7cbc2007-09-10 20:33:04 +0000268 /// Insert collected methods declarations into the @interface object.
Steve Naroff25aace82007-10-03 21:00:46 +0000269 Actions.ActOnAddMethodsToObjcDecl(CurScope, interfaceDecl,
270 &allMethods[0], allMethods.size());
Steve Naroff0bbffd82007-08-22 16:35:03 +0000271}
272
Fariborz Jahanian6668b8c2007-08-31 16:11:31 +0000273/// Parse property attribute declarations.
274///
275/// property-attr-decl: '(' property-attrlist ')'
276/// property-attrlist:
277/// property-attribute
278/// property-attrlist ',' property-attribute
279/// property-attribute:
280/// getter '=' identifier
281/// setter '=' identifier ':'
282/// readonly
283/// readwrite
284/// assign
285/// retain
286/// copy
287/// nonatomic
288///
289void Parser::ParseObjCPropertyAttribute (DeclTy *interfaceDecl) {
290 SourceLocation loc = ConsumeParen(); // consume '('
291 while (isObjCPropertyAttribute()) {
292 const IdentifierInfo *II = Tok.getIdentifierInfo();
293 // getter/setter require extra treatment.
294 if (II == ObjcPropertyAttrs[objc_getter] ||
295 II == ObjcPropertyAttrs[objc_setter]) {
296 // skip getter/setter part.
297 SourceLocation loc = ConsumeToken();
298 if (Tok.getKind() == tok::equal) {
299 loc = ConsumeToken();
300 if (Tok.getKind() == tok::identifier) {
301 if (II == ObjcPropertyAttrs[objc_setter]) {
302 loc = ConsumeToken(); // consume method name
303 if (Tok.getKind() != tok::colon) {
304 Diag(loc, diag::err_expected_colon);
305 SkipUntil(tok::r_paren,true,true);
306 break;
307 }
308 }
309 }
310 else {
311 Diag(loc, diag::err_expected_ident);
312 SkipUntil(tok::r_paren,true,true);
313 break;
314 }
315 }
316 else {
317 Diag(loc, diag::err_objc_expected_equal);
318 SkipUntil(tok::r_paren,true,true);
319 break;
320 }
321 }
322 ConsumeToken(); // consume last attribute token
323 if (Tok.getKind() == tok::comma) {
324 loc = ConsumeToken();
325 continue;
326 }
327 if (Tok.getKind() == tok::r_paren)
328 break;
329 Diag(loc, diag::err_expected_rparen);
330 SkipUntil(tok::semi);
331 return;
332 }
333 if (Tok.getKind() == tok::r_paren)
334 ConsumeParen();
335 else {
336 Diag(loc, diag::err_objc_expected_property_attr);
337 SkipUntil(tok::r_paren); // recover from error inside attribute list
338 }
339}
340
341/// Main routine to parse property declaration.
342///
343/// @property property-attr-decl[opt] property-component-decl ';'
344///
345void Parser::ParseObjCPropertyDecl(DeclTy *interfaceDecl) {
346 assert(Tok.isObjCAtKeyword(tok::objc_property) &&
347 "ParseObjCPropertyDecl(): Expected @property");
348 ConsumeToken(); // the "property" identifier
349 // Parse property attribute list, if any.
350 if (Tok.getKind() == tok::l_paren) {
351 // property has attribute list.
352 ParseObjCPropertyAttribute(0/*FIXME*/);
353 }
354 // Parse declaration portion of @property.
355 llvm::SmallVector<DeclTy*, 32> PropertyDecls;
356 ParseStructDeclaration(interfaceDecl, PropertyDecls);
357 if (Tok.getKind() == tok::semi)
358 ConsumeToken();
359 else {
360 Diag(Tok, diag::err_expected_semi_decl_list);
361 SkipUntil(tok::r_brace, true, true);
362 }
Chris Lattner4b009652007-07-25 00:24:17 +0000363}
Steve Narofffb367882007-08-20 21:31:48 +0000364
Steve Naroff81f1bba2007-09-06 21:24:23 +0000365/// objc-method-proto:
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000366/// objc-instance-method objc-method-decl objc-method-attributes[opt]
Steve Naroff81f1bba2007-09-06 21:24:23 +0000367/// objc-class-method objc-method-decl objc-method-attributes[opt]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000368///
369/// objc-instance-method: '-'
370/// objc-class-method: '+'
371///
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000372/// objc-method-attributes: [OBJC2]
373/// __attribute__((deprecated))
374///
Fariborz Jahanian8b5ab6f2007-09-18 00:25:23 +0000375Parser::DeclTy *Parser::ParseObjCMethodPrototype(DeclTy *IDecl,
376 tok::ObjCKeywordKind MethodImplKind) {
Steve Naroff0bbffd82007-08-22 16:35:03 +0000377 assert((Tok.getKind() == tok::minus || Tok.getKind() == tok::plus) &&
378 "expected +/-");
379
380 tok::TokenKind methodType = Tok.getKind();
381 SourceLocation methodLoc = ConsumeToken();
382
Fariborz Jahanian8b5ab6f2007-09-18 00:25:23 +0000383 DeclTy *MDecl = ParseObjCMethodDecl(methodType, methodLoc, MethodImplKind);
Steve Naroff81f1bba2007-09-06 21:24:23 +0000384 // Since this rule is used for both method declarations and definitions,
Steve Narofffaed3bf2007-09-10 20:51:04 +0000385 // the caller is (optionally) responsible for consuming the ';'.
Steve Naroff304ed392007-09-05 23:30:30 +0000386 return MDecl;
Steve Naroff0bbffd82007-08-22 16:35:03 +0000387}
388
389/// objc-selector:
390/// identifier
391/// one of
392/// enum struct union if else while do for switch case default
393/// break continue return goto asm sizeof typeof __alignof
394/// unsigned long const short volatile signed restrict _Complex
395/// in out inout bycopy byref oneway int char float double void _Bool
396///
397IdentifierInfo *Parser::ParseObjCSelector() {
398 tok::TokenKind tKind = Tok.getKind();
399 IdentifierInfo *II = 0;
Fariborz Jahanian171ceb52007-09-27 19:52:15 +0000400 switch (tKind) {
401 case tok::identifier:
402 case tok::kw_typeof:
403 case tok::kw___alignof:
404 case tok::kw_auto:
405 case tok::kw_break:
406 case tok::kw_case:
407 case tok::kw_char:
408 case tok::kw_const:
409 case tok::kw_continue:
410 case tok::kw_default:
411 case tok::kw_do:
412 case tok::kw_double:
413 case tok::kw_else:
414 case tok::kw_enum:
415 case tok::kw_extern:
416 case tok::kw_float:
417 case tok::kw_for:
418 case tok::kw_goto:
419 case tok::kw_if:
420 case tok::kw_inline:
421 case tok::kw_int:
422 case tok::kw_long:
423 case tok::kw_register:
424 case tok::kw_restrict:
425 case tok::kw_return:
426 case tok::kw_short:
427 case tok::kw_signed:
428 case tok::kw_sizeof:
429 case tok::kw_static:
430 case tok::kw_struct:
431 case tok::kw_switch:
432 case tok::kw_typedef:
433 case tok::kw_union:
434 case tok::kw_unsigned:
435 case tok::kw_void:
436 case tok::kw_volatile:
437 case tok::kw_while:
438 case tok::kw__Bool:
439 case tok::kw__Complex:
440 II = Tok.getIdentifierInfo();
441 ConsumeToken();
442 default:
443 break;
444 }
Steve Naroff0bbffd82007-08-22 16:35:03 +0000445
Steve Naroff0bbffd82007-08-22 16:35:03 +0000446 return II;
447}
448
Steve Naroffa8ee2262007-08-22 23:18:22 +0000449/// objc-type-qualifier: one of
450/// in out inout bycopy byref oneway
451///
Steve Naroffa8ee2262007-08-22 23:18:22 +0000452bool Parser::isObjCTypeQualifier() {
453 if (Tok.getKind() == tok::identifier) {
Chris Lattner32352462007-08-29 22:54:08 +0000454 const IdentifierInfo *II = Tok.getIdentifierInfo();
455 for (unsigned i = 0; i < objc_NumQuals; ++i)
456 if (II == ObjcTypeQuals[i]) return true;
Steve Naroffa8ee2262007-08-22 23:18:22 +0000457 }
458 return false;
459}
460
Fariborz Jahanian6668b8c2007-08-31 16:11:31 +0000461/// property-attrlist: one of
462/// readonly getter setter assign retain copy nonatomic
463///
464bool Parser::isObjCPropertyAttribute() {
465 if (Tok.getKind() == tok::identifier) {
466 const IdentifierInfo *II = Tok.getIdentifierInfo();
467 for (unsigned i = 0; i < objc_NumAttrs; ++i)
468 if (II == ObjcPropertyAttrs[i]) return true;
469 }
470 return false;
471}
472
Steve Naroff0bbffd82007-08-22 16:35:03 +0000473/// objc-type-name:
474/// '(' objc-type-qualifiers[opt] type-name ')'
475/// '(' objc-type-qualifiers[opt] ')'
476///
477/// objc-type-qualifiers:
478/// objc-type-qualifier
479/// objc-type-qualifiers objc-type-qualifier
480///
Steve Naroff304ed392007-09-05 23:30:30 +0000481Parser::TypeTy *Parser::ParseObjCTypeName() {
Steve Naroff0bbffd82007-08-22 16:35:03 +0000482 assert(Tok.getKind() == tok::l_paren && "expected (");
483
484 SourceLocation LParenLoc = ConsumeParen(), RParenLoc;
Chris Lattner265c8172007-09-27 15:15:46 +0000485 TypeTy *Ty = 0;
Steve Naroff0bbffd82007-08-22 16:35:03 +0000486
Steve Naroffa8ee2262007-08-22 23:18:22 +0000487 while (isObjCTypeQualifier())
488 ConsumeToken();
489
Steve Naroff0bbffd82007-08-22 16:35:03 +0000490 if (isTypeSpecifierQualifier()) {
Steve Naroff304ed392007-09-05 23:30:30 +0000491 Ty = ParseTypeName();
492 // FIXME: back when Sema support is in place...
493 // assert(Ty && "Parser::ParseObjCTypeName(): missing type");
Steve Naroff0bbffd82007-08-22 16:35:03 +0000494 }
495 if (Tok.getKind() != tok::r_paren) {
496 MatchRHSPunctuation(tok::r_paren, LParenLoc);
Steve Naroff304ed392007-09-05 23:30:30 +0000497 return 0; // FIXME: decide how we want to handle this error...
Steve Naroff0bbffd82007-08-22 16:35:03 +0000498 }
499 RParenLoc = ConsumeParen();
Steve Naroff304ed392007-09-05 23:30:30 +0000500 return Ty;
Steve Naroff0bbffd82007-08-22 16:35:03 +0000501}
502
503/// objc-method-decl:
504/// objc-selector
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000505/// objc-keyword-selector objc-parmlist[opt]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000506/// objc-type-name objc-selector
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000507/// objc-type-name objc-keyword-selector objc-parmlist[opt]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000508///
509/// objc-keyword-selector:
Steve Naroff72f17fb2007-08-22 22:17:26 +0000510/// objc-keyword-decl
Steve Naroff0bbffd82007-08-22 16:35:03 +0000511/// objc-keyword-selector objc-keyword-decl
512///
513/// objc-keyword-decl:
Steve Naroff72f17fb2007-08-22 22:17:26 +0000514/// objc-selector ':' objc-type-name objc-keyword-attributes[opt] identifier
515/// objc-selector ':' objc-keyword-attributes[opt] identifier
516/// ':' objc-type-name objc-keyword-attributes[opt] identifier
517/// ':' objc-keyword-attributes[opt] identifier
Steve Naroff0bbffd82007-08-22 16:35:03 +0000518///
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000519/// objc-parmlist:
520/// objc-parms objc-ellipsis[opt]
Steve Naroff0bbffd82007-08-22 16:35:03 +0000521///
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000522/// objc-parms:
523/// objc-parms , parameter-declaration
Steve Naroff0bbffd82007-08-22 16:35:03 +0000524///
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000525/// objc-ellipsis:
Steve Naroff0bbffd82007-08-22 16:35:03 +0000526/// , ...
527///
Steve Naroff72f17fb2007-08-22 22:17:26 +0000528/// objc-keyword-attributes: [OBJC2]
529/// __attribute__((unused))
530///
Steve Naroff4ed9d662007-09-27 14:38:14 +0000531Parser::DeclTy *Parser::ParseObjCMethodDecl(tok::TokenKind mType,
532 SourceLocation mLoc,
533 tok::ObjCKeywordKind MethodImplKind)
534{
Steve Naroff304ed392007-09-05 23:30:30 +0000535 TypeTy *ReturnType = 0;
Fariborz Jahanian3dc7cbc2007-09-10 20:33:04 +0000536 AttributeList *methodAttrs = 0;
Steve Naroff304ed392007-09-05 23:30:30 +0000537
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000538 // Parse the return type.
Steve Naroff0bbffd82007-08-22 16:35:03 +0000539 if (Tok.getKind() == tok::l_paren)
Steve Naroff304ed392007-09-05 23:30:30 +0000540 ReturnType = ParseObjCTypeName();
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000541 IdentifierInfo *selIdent = ParseObjCSelector();
Steve Naroff304ed392007-09-05 23:30:30 +0000542
Steve Naroff4ed9d662007-09-27 14:38:14 +0000543 llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
544 llvm::SmallVector<Action::TypeTy *, 12> KeyTypes;
545 llvm::SmallVector<IdentifierInfo *, 12> ArgNames;
546
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000547 if (Tok.getKind() == tok::colon) {
Steve Naroff4ed9d662007-09-27 14:38:14 +0000548 Action::TypeTy *TypeInfo;
Steve Naroff304ed392007-09-05 23:30:30 +0000549
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000550 while (1) {
Steve Naroff4ed9d662007-09-27 14:38:14 +0000551 KeyIdents.push_back(selIdent);
Steve Naroff304ed392007-09-05 23:30:30 +0000552
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000553 // Each iteration parses a single keyword argument.
554 if (Tok.getKind() != tok::colon) {
555 Diag(Tok, diag::err_expected_colon);
556 break;
557 }
Steve Naroff4ed9d662007-09-27 14:38:14 +0000558 ConsumeToken(); // Eat the ':'.
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000559 if (Tok.getKind() == tok::l_paren) // Parse the argument type.
Steve Naroff4ed9d662007-09-27 14:38:14 +0000560 TypeInfo = ParseObjCTypeName();
561 else
562 TypeInfo = 0;
563 KeyTypes.push_back(TypeInfo);
564
Steve Naroff72f17fb2007-08-22 22:17:26 +0000565 // If attributes exist before the argument name, parse them.
Steve Naroffa7f62782007-08-23 19:56:30 +0000566 if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
Steve Naroff4ed9d662007-09-27 14:38:14 +0000567 ParseAttributes(); // FIXME: pass attributes through.
Steve Naroff72f17fb2007-08-22 22:17:26 +0000568
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000569 if (Tok.getKind() != tok::identifier) {
570 Diag(Tok, diag::err_expected_ident); // missing argument name.
571 break;
572 }
Steve Naroff4ed9d662007-09-27 14:38:14 +0000573 ArgNames.push_back(Tok.getIdentifierInfo());
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000574 ConsumeToken(); // Eat the identifier.
Steve Naroff304ed392007-09-05 23:30:30 +0000575
Steve Naroff253118b2007-09-17 20:25:27 +0000576 // Check for another keyword selector.
Steve Naroff304ed392007-09-05 23:30:30 +0000577 selIdent = ParseObjCSelector();
578 if (!selIdent && Tok.getKind() != tok::colon)
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000579 break;
580 // We have a selector or a colon, continue parsing.
581 }
582 // Parse the (optional) parameter list.
583 while (Tok.getKind() == tok::comma) {
584 ConsumeToken();
585 if (Tok.getKind() == tok::ellipsis) {
586 ConsumeToken();
587 break;
588 }
Fariborz Jahanian1e534dc2007-09-05 19:52:07 +0000589 // Parse the c-style argument declaration-specifier.
590 DeclSpec DS;
591 ParseDeclarationSpecifiers(DS);
592 // Parse the declarator.
593 Declarator ParmDecl(DS, Declarator::PrototypeContext);
594 ParseDeclarator(ParmDecl);
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000595 }
Steve Naroff304ed392007-09-05 23:30:30 +0000596 // FIXME: Add support for optional parmameter list...
Fariborz Jahanian3dc7cbc2007-09-10 20:33:04 +0000597 // If attributes exist after the method, parse them.
598 if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
599 methodAttrs = ParseAttributes();
Steve Narofff9e80db2007-10-05 18:42:47 +0000600
601 unsigned nKeys = KeyIdents.size();
602 Selector Sel = (nKeys == 1) ?
603 PP.getSelectorTable().getUnarySelector(KeyIdents[0]) :
604 PP.getSelectorTable().getKeywordSelector(nKeys, &KeyIdents[0]);
Steve Naroffb4dfe362007-10-02 22:39:18 +0000605 return Actions.ActOnMethodDeclaration(mLoc, mType, ReturnType, Sel,
606 &KeyTypes[0], &ArgNames[0],
607 methodAttrs, MethodImplKind);
Steve Naroff09a0c4c2007-08-22 18:35:33 +0000608 } else if (!selIdent) {
609 Diag(Tok, diag::err_expected_ident); // missing selector name.
610 }
Fariborz Jahanian3dc7cbc2007-09-10 20:33:04 +0000611 // If attributes exist after the method, parse them.
612 if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
613 methodAttrs = ParseAttributes();
614
Steve Narofff9e80db2007-10-05 18:42:47 +0000615 Selector Sel = PP.getSelectorTable().getNullarySelector(selIdent);
Steve Naroffb4dfe362007-10-02 22:39:18 +0000616 return Actions.ActOnMethodDeclaration(mLoc, mType, ReturnType, Sel,
617 0, 0, methodAttrs, MethodImplKind);
Steve Naroff0bbffd82007-08-22 16:35:03 +0000618}
619
Steve Narofffb367882007-08-20 21:31:48 +0000620/// objc-protocol-refs:
621/// '<' identifier-list '>'
622///
Steve Naroff304ed392007-09-05 23:30:30 +0000623bool Parser::ParseObjCProtocolReferences(
624 llvm::SmallVectorImpl<IdentifierInfo*> &ProtocolRefs) {
Steve Narofffb367882007-08-20 21:31:48 +0000625 assert(Tok.getKind() == tok::less && "expected <");
626
627 ConsumeToken(); // the "<"
Steve Narofffb367882007-08-20 21:31:48 +0000628
629 while (1) {
630 if (Tok.getKind() != tok::identifier) {
631 Diag(Tok, diag::err_expected_ident);
632 SkipUntil(tok::greater);
633 return true;
634 }
635 ProtocolRefs.push_back(Tok.getIdentifierInfo());
636 ConsumeToken();
637
638 if (Tok.getKind() != tok::comma)
639 break;
640 ConsumeToken();
641 }
642 // Consume the '>'.
643 return ExpectAndConsume(tok::greater, diag::err_expected_greater);
644}
645
646/// objc-class-instance-variables:
647/// '{' objc-instance-variable-decl-list[opt] '}'
648///
649/// objc-instance-variable-decl-list:
650/// objc-visibility-spec
651/// objc-instance-variable-decl ';'
652/// ';'
653/// objc-instance-variable-decl-list objc-visibility-spec
654/// objc-instance-variable-decl-list objc-instance-variable-decl ';'
655/// objc-instance-variable-decl-list ';'
656///
657/// objc-visibility-spec:
658/// @private
659/// @protected
660/// @public
Steve Naroffc4474992007-08-21 21:17:12 +0000661/// @package [OBJC2]
Steve Narofffb367882007-08-20 21:31:48 +0000662///
663/// objc-instance-variable-decl:
664/// struct-declaration
665///
Steve Naroff81f1bba2007-09-06 21:24:23 +0000666void Parser::ParseObjCClassInstanceVariables(DeclTy *interfaceDecl) {
Steve Naroffc4474992007-08-21 21:17:12 +0000667 assert(Tok.getKind() == tok::l_brace && "expected {");
Steve Naroff81f1bba2007-09-06 21:24:23 +0000668 llvm::SmallVector<DeclTy*, 16> IvarDecls;
Fariborz Jahanian3957dae2007-09-13 20:56:13 +0000669 llvm::SmallVector<DeclTy*, 32> AllIvarDecls;
670 llvm::SmallVector<tok::ObjCKeywordKind, 32> AllVisibilities;
Steve Naroffc4474992007-08-21 21:17:12 +0000671
672 SourceLocation LBraceLoc = ConsumeBrace(); // the "{"
Steve Naroffc4474992007-08-21 21:17:12 +0000673
Fariborz Jahanian3957dae2007-09-13 20:56:13 +0000674 tok::ObjCKeywordKind visibility = tok::objc_private;
Steve Naroffc4474992007-08-21 21:17:12 +0000675 // While we still have something to read, read the instance variables.
676 while (Tok.getKind() != tok::r_brace &&
677 Tok.getKind() != tok::eof) {
678 // Each iteration of this loop reads one objc-instance-variable-decl.
679
680 // Check for extraneous top-level semicolon.
681 if (Tok.getKind() == tok::semi) {
682 Diag(Tok, diag::ext_extra_struct_semi);
683 ConsumeToken();
684 continue;
685 }
686 // Set the default visibility to private.
Steve Naroffc4474992007-08-21 21:17:12 +0000687 if (Tok.getKind() == tok::at) { // parse objc-visibility-spec
688 ConsumeToken(); // eat the @ sign
Steve Naroff87c329f2007-08-23 18:16:40 +0000689 switch (Tok.getObjCKeywordID()) {
Steve Naroffc4474992007-08-21 21:17:12 +0000690 case tok::objc_private:
691 case tok::objc_public:
692 case tok::objc_protected:
693 case tok::objc_package:
Steve Naroff87c329f2007-08-23 18:16:40 +0000694 visibility = Tok.getObjCKeywordID();
Steve Naroffc4474992007-08-21 21:17:12 +0000695 ConsumeToken();
696 continue;
697 default:
698 Diag(Tok, diag::err_objc_illegal_visibility_spec);
699 ConsumeToken();
700 continue;
701 }
702 }
703 ParseStructDeclaration(interfaceDecl, IvarDecls);
Fariborz Jahanian3957dae2007-09-13 20:56:13 +0000704 for (unsigned i = 0; i < IvarDecls.size(); i++) {
705 AllIvarDecls.push_back(IvarDecls[i]);
706 AllVisibilities.push_back(visibility);
707 }
Steve Naroff81f1bba2007-09-06 21:24:23 +0000708 IvarDecls.clear();
709
Steve Naroffc4474992007-08-21 21:17:12 +0000710 if (Tok.getKind() == tok::semi) {
711 ConsumeToken();
712 } else if (Tok.getKind() == tok::r_brace) {
713 Diag(Tok.getLocation(), diag::ext_expected_semi_decl_list);
714 break;
715 } else {
716 Diag(Tok, diag::err_expected_semi_decl_list);
717 // Skip to end of block or statement
718 SkipUntil(tok::r_brace, true, true);
719 }
720 }
Fariborz Jahanian3957dae2007-09-13 20:56:13 +0000721 if (AllIvarDecls.size()) { // Check for {} - no ivars in braces
Fariborz Jahanian0c5affb2007-09-29 00:54:24 +0000722 Actions.ActOnFields(CurScope, LBraceLoc, interfaceDecl,
Steve Naroff0acc9c92007-09-15 18:49:24 +0000723 &AllIvarDecls[0], AllIvarDecls.size(),
724 &AllVisibilities[0]);
Fariborz Jahanian3957dae2007-09-13 20:56:13 +0000725 }
Steve Naroffc4474992007-08-21 21:17:12 +0000726 MatchRHSPunctuation(tok::r_brace, LBraceLoc);
727 return;
Chris Lattner4b009652007-07-25 00:24:17 +0000728}
Steve Narofffb367882007-08-20 21:31:48 +0000729
730/// objc-protocol-declaration:
731/// objc-protocol-definition
732/// objc-protocol-forward-reference
733///
734/// objc-protocol-definition:
735/// @protocol identifier
736/// objc-protocol-refs[opt]
Steve Naroff81f1bba2007-09-06 21:24:23 +0000737/// objc-interface-decl-list
Steve Narofffb367882007-08-20 21:31:48 +0000738/// @end
739///
740/// objc-protocol-forward-reference:
741/// @protocol identifier-list ';'
742///
743/// "@protocol identifier ;" should be resolved as "@protocol
Steve Naroff81f1bba2007-09-06 21:24:23 +0000744/// identifier-list ;": objc-interface-decl-list may not start with a
Steve Narofffb367882007-08-20 21:31:48 +0000745/// semicolon in the first alternative if objc-protocol-refs are omitted.
746
Steve Naroff72f17fb2007-08-22 22:17:26 +0000747Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc) {
Steve Naroff87c329f2007-08-23 18:16:40 +0000748 assert(Tok.isObjCAtKeyword(tok::objc_protocol) &&
Steve Naroff72f17fb2007-08-22 22:17:26 +0000749 "ParseObjCAtProtocolDeclaration(): Expected @protocol");
750 ConsumeToken(); // the "protocol" identifier
751
752 if (Tok.getKind() != tok::identifier) {
753 Diag(Tok, diag::err_expected_ident); // missing protocol name.
754 return 0;
755 }
756 // Save the protocol name, then consume it.
757 IdentifierInfo *protocolName = Tok.getIdentifierInfo();
758 SourceLocation nameLoc = ConsumeToken();
759
Fariborz Jahanianc716c942007-09-21 15:40:54 +0000760 llvm::SmallVector<IdentifierInfo *, 8> ProtocolRefs;
761 if (Tok.getKind() == tok::semi) { // forward declaration of one protocol.
Steve Naroff72f17fb2007-08-22 22:17:26 +0000762 ConsumeToken();
Fariborz Jahanianc716c942007-09-21 15:40:54 +0000763 ProtocolRefs.push_back(protocolName);
Steve Naroff72f17fb2007-08-22 22:17:26 +0000764 }
765 if (Tok.getKind() == tok::comma) { // list of forward declarations.
766 // Parse the list of forward declarations.
Steve Naroff72f17fb2007-08-22 22:17:26 +0000767 ProtocolRefs.push_back(protocolName);
768
769 while (1) {
770 ConsumeToken(); // the ','
771 if (Tok.getKind() != tok::identifier) {
772 Diag(Tok, diag::err_expected_ident);
773 SkipUntil(tok::semi);
774 return 0;
775 }
776 ProtocolRefs.push_back(Tok.getIdentifierInfo());
777 ConsumeToken(); // the identifier
778
779 if (Tok.getKind() != tok::comma)
780 break;
781 }
782 // Consume the ';'.
783 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after, "@protocol"))
784 return 0;
Steve Naroff72f17fb2007-08-22 22:17:26 +0000785 }
Fariborz Jahanianc716c942007-09-21 15:40:54 +0000786 if (ProtocolRefs.size() > 0)
Steve Naroffb4dfe362007-10-02 22:39:18 +0000787 return Actions.ActOnForwardProtocolDeclaration(CurScope, AtLoc,
788 &ProtocolRefs[0],
789 ProtocolRefs.size());
Steve Naroff72f17fb2007-08-22 22:17:26 +0000790 // Last, and definitely not least, parse a protocol declaration.
791 if (Tok.getKind() == tok::less) {
Steve Naroff304ed392007-09-05 23:30:30 +0000792 if (ParseObjCProtocolReferences(ProtocolRefs))
Steve Naroff72f17fb2007-08-22 22:17:26 +0000793 return 0;
794 }
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +0000795
Steve Naroff25aace82007-10-03 21:00:46 +0000796 DeclTy *ProtoType = Actions.ActOnStartProtocolInterface(CurScope, AtLoc,
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +0000797 protocolName, nameLoc,
798 &ProtocolRefs[0],
799 ProtocolRefs.size());
800 ParseObjCInterfaceDeclList(ProtoType, tok::objc_protocol);
Steve Naroff72f17fb2007-08-22 22:17:26 +0000801
802 // The @ sign was already consumed by ParseObjCInterfaceDeclList().
Steve Naroff87c329f2007-08-23 18:16:40 +0000803 if (Tok.isObjCAtKeyword(tok::objc_end)) {
Steve Naroff72f17fb2007-08-22 22:17:26 +0000804 ConsumeToken(); // the "end" identifier
805 return 0;
806 }
807 Diag(Tok, diag::err_objc_missing_end);
Steve Narofffb367882007-08-20 21:31:48 +0000808 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +0000809}
Steve Narofffb367882007-08-20 21:31:48 +0000810
811/// objc-implementation:
812/// objc-class-implementation-prologue
813/// objc-category-implementation-prologue
814///
815/// objc-class-implementation-prologue:
816/// @implementation identifier objc-superclass[opt]
817/// objc-class-instance-variables[opt]
818///
819/// objc-category-implementation-prologue:
820/// @implementation identifier ( identifier )
821
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000822Parser::DeclTy *Parser::ParseObjCAtImplementationDeclaration(
823 SourceLocation atLoc) {
824 assert(Tok.isObjCAtKeyword(tok::objc_implementation) &&
825 "ParseObjCAtImplementationDeclaration(): Expected @implementation");
826 ConsumeToken(); // the "implementation" identifier
827
828 if (Tok.getKind() != tok::identifier) {
829 Diag(Tok, diag::err_expected_ident); // missing class or category name.
830 return 0;
831 }
832 // We have a class or category name - consume it.
Fariborz Jahanianc091b5d2007-09-25 18:38:09 +0000833 IdentifierInfo *nameId = Tok.getIdentifierInfo();
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000834 SourceLocation nameLoc = ConsumeToken(); // consume class or category name
835
836 if (Tok.getKind() == tok::l_paren) {
837 // we have a category implementation.
838 SourceLocation lparenLoc = ConsumeParen();
839 SourceLocation categoryLoc, rparenLoc;
840 IdentifierInfo *categoryId = 0;
841
842 if (Tok.getKind() == tok::identifier) {
843 categoryId = Tok.getIdentifierInfo();
844 categoryLoc = ConsumeToken();
845 } else {
846 Diag(Tok, diag::err_expected_ident); // missing category name.
847 return 0;
848 }
849 if (Tok.getKind() != tok::r_paren) {
850 Diag(Tok, diag::err_expected_rparen);
851 SkipUntil(tok::r_paren, false); // don't stop at ';'
852 return 0;
853 }
854 rparenLoc = ConsumeParen();
Steve Naroff25aace82007-10-03 21:00:46 +0000855 DeclTy *ImplCatType = Actions.ActOnStartCategoryImplementation(CurScope,
Fariborz Jahaniana91aa322007-10-02 16:38:50 +0000856 atLoc, nameId, nameLoc, categoryId,
857 categoryLoc);
858 return ImplCatType;
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000859 }
860 // We have a class implementation
Fariborz Jahanianc091b5d2007-09-25 18:38:09 +0000861 SourceLocation superClassLoc;
862 IdentifierInfo *superClassId = 0;
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000863 if (Tok.getKind() == tok::colon) {
864 // We have a super class
865 ConsumeToken();
866 if (Tok.getKind() != tok::identifier) {
867 Diag(Tok, diag::err_expected_ident); // missing super class name.
868 return 0;
869 }
Fariborz Jahanianc091b5d2007-09-25 18:38:09 +0000870 superClassId = Tok.getIdentifierInfo();
871 superClassLoc = ConsumeToken(); // Consume super class name
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000872 }
Steve Naroff25aace82007-10-03 21:00:46 +0000873 DeclTy *ImplClsType = Actions.ActOnStartClassImplementation(CurScope,
874 atLoc, nameId, nameLoc,
Fariborz Jahanianc091b5d2007-09-25 18:38:09 +0000875 superClassId, superClassLoc);
876
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000877 if (Tok.getKind() == tok::l_brace)
Fariborz Jahanianc091b5d2007-09-25 18:38:09 +0000878 ParseObjCClassInstanceVariables(ImplClsType/*FIXME*/); // we have ivars
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000879
Fariborz Jahanian1e4e82f2007-09-27 18:57:03 +0000880 return ImplClsType;
Chris Lattner4b009652007-07-25 00:24:17 +0000881}
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000882Parser::DeclTy *Parser::ParseObjCAtEndDeclaration(SourceLocation atLoc) {
883 assert(Tok.isObjCAtKeyword(tok::objc_end) &&
884 "ParseObjCAtEndDeclaration(): Expected @end");
885 ConsumeToken(); // the "end" identifier
Fariborz Jahanian1e4e82f2007-09-27 18:57:03 +0000886 if (ObjcImpDecl) {
887 // Checking is not necessary except that a parse error might have caused
888 // @implementation not to have been parsed to completion and ObjcImpDecl
889 // could be 0.
890 /// Insert collected methods declarations into the @interface object.
Steve Naroff25aace82007-10-03 21:00:46 +0000891 Actions.ActOnAddMethodsToObjcDecl(CurScope, ObjcImpDecl,
892 &AllImplMethods[0],AllImplMethods.size());
Fariborz Jahanian1e4e82f2007-09-27 18:57:03 +0000893 ObjcImpDecl = 0;
894 AllImplMethods.clear();
895 }
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000896
Steve Narofffb367882007-08-20 21:31:48 +0000897 return 0;
898}
Fariborz Jahanianb62aff32007-09-04 19:26:51 +0000899
900/// compatibility-alias-decl:
901/// @compatibility_alias alias-name class-name ';'
902///
903Parser::DeclTy *Parser::ParseObjCAtAliasDeclaration(SourceLocation atLoc) {
904 assert(Tok.isObjCAtKeyword(tok::objc_compatibility_alias) &&
905 "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
906 ConsumeToken(); // consume compatibility_alias
907 if (Tok.getKind() != tok::identifier) {
908 Diag(Tok, diag::err_expected_ident);
909 return 0;
910 }
911 ConsumeToken(); // consume alias-name
912 if (Tok.getKind() != tok::identifier) {
913 Diag(Tok, diag::err_expected_ident);
914 return 0;
915 }
916 ConsumeToken(); // consume class-name;
917 if (Tok.getKind() != tok::semi)
Fariborz Jahanian6c30fa62007-09-04 21:42:12 +0000918 Diag(Tok, diag::err_expected_semi_after, "@compatibility_alias");
Steve Narofffb367882007-08-20 21:31:48 +0000919 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +0000920}
921
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000922/// property-synthesis:
923/// @synthesize property-ivar-list ';'
924///
925/// property-ivar-list:
926/// property-ivar
927/// property-ivar-list ',' property-ivar
928///
929/// property-ivar:
930/// identifier
931/// identifier '=' identifier
932///
933Parser::DeclTy *Parser::ParseObjCPropertySynthesize(SourceLocation atLoc) {
934 assert(Tok.isObjCAtKeyword(tok::objc_synthesize) &&
935 "ParseObjCPropertyDynamic(): Expected '@synthesize'");
936 SourceLocation loc = ConsumeToken(); // consume dynamic
937 if (Tok.getKind() != tok::identifier) {
938 Diag(Tok, diag::err_expected_ident);
939 return 0;
940 }
941 while (Tok.getKind() == tok::identifier) {
942 ConsumeToken(); // consume property name
943 if (Tok.getKind() == tok::equal) {
944 // property '=' ivar-name
945 ConsumeToken(); // consume '='
946 if (Tok.getKind() != tok::identifier) {
947 Diag(Tok, diag::err_expected_ident);
948 break;
949 }
950 ConsumeToken(); // consume ivar-name
951 }
952 if (Tok.getKind() != tok::comma)
953 break;
954 ConsumeToken(); // consume ','
955 }
956 if (Tok.getKind() != tok::semi)
957 Diag(Tok, diag::err_expected_semi_after, "@synthesize");
958 return 0;
Chris Lattner4b009652007-07-25 00:24:17 +0000959}
960
Fariborz Jahanian027c23b2007-09-01 00:26:16 +0000961/// property-dynamic:
962/// @dynamic property-list
963///
964/// property-list:
965/// identifier
966/// property-list ',' identifier
967///
968Parser::DeclTy *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
969 assert(Tok.isObjCAtKeyword(tok::objc_dynamic) &&
970 "ParseObjCPropertyDynamic(): Expected '@dynamic'");
971 SourceLocation loc = ConsumeToken(); // consume dynamic
972 if (Tok.getKind() != tok::identifier) {
973 Diag(Tok, diag::err_expected_ident);
974 return 0;
975 }
976 while (Tok.getKind() == tok::identifier) {
977 ConsumeToken(); // consume property name
978 if (Tok.getKind() != tok::comma)
979 break;
980 ConsumeToken(); // consume ','
981 }
982 if (Tok.getKind() != tok::semi)
983 Diag(Tok, diag::err_expected_semi_after, "@dynamic");
984 return 0;
985}
Fariborz Jahanian64b864e2007-09-19 19:14:32 +0000986
987/// objc-throw-statement:
988/// throw expression[opt];
989///
Fariborz Jahanian37c9c612007-10-04 20:19:06 +0000990Parser::DeclTy *Parser::ParseObjCThrowStmt(SourceLocation atLoc) {
Fariborz Jahanian64b864e2007-09-19 19:14:32 +0000991 ConsumeToken(); // consume throw
992 if (Tok.getKind() != tok::semi) {
Fariborz Jahanian37c9c612007-10-04 20:19:06 +0000993 ExprResult Res = ParseExpression();
Fariborz Jahanian64b864e2007-09-19 19:14:32 +0000994 if (Res.isInvalid) {
995 SkipUntil(tok::semi);
996 return 0;
997 }
998 }
999 return 0;
1000}
1001
1002/// objc-try-catch-statement:
1003/// @try compound-statement objc-catch-list[opt]
1004/// @try compound-statement objc-catch-list[opt] @finally compound-statement
1005///
1006/// objc-catch-list:
1007/// @catch ( parameter-declaration ) compound-statement
1008/// objc-catch-list @catch ( catch-parameter-declaration ) compound-statement
1009/// catch-parameter-declaration:
1010/// parameter-declaration
1011/// '...' [OBJC2]
1012///
Fariborz Jahanian37c9c612007-10-04 20:19:06 +00001013Parser::DeclTy *Parser::ParseObjCTryStmt(SourceLocation atLoc) {
Fariborz Jahanian64b864e2007-09-19 19:14:32 +00001014 bool catch_or_finally_seen = false;
1015 ConsumeToken(); // consume try
1016 if (Tok.getKind() != tok::l_brace) {
1017 Diag (Tok, diag::err_expected_lbrace);
1018 return 0;
1019 }
1020 StmtResult TryBody = ParseCompoundStatementBody();
1021 while (Tok.getKind() == tok::at) {
1022 ConsumeToken();
1023 if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_catch) {
1024 SourceLocation catchLoc = ConsumeToken(); // consume catch
1025 if (Tok.getKind() == tok::l_paren) {
1026 ConsumeParen();
1027 if (Tok.getKind() != tok::ellipsis) {
1028 DeclSpec DS;
1029 ParseDeclarationSpecifiers(DS);
1030 // Parse the parameter-declaration.
1031 // FIXME: BlockContext may not be the right context!
1032 Declarator ParmDecl(DS, Declarator::BlockContext);
1033 ParseDeclarator(ParmDecl);
1034 }
1035 else
1036 ConsumeToken(); // consume '...'
1037 ConsumeParen();
1038 StmtResult CatchMody = ParseCompoundStatementBody();
1039 }
1040 else {
1041 Diag(catchLoc, diag::err_expected_lparen_after, "@catch clause");
1042 return 0;
1043 }
1044 catch_or_finally_seen = true;
1045 }
1046 else if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_finally) {
1047 ConsumeToken(); // consume finally
1048 StmtResult FinallyBody = ParseCompoundStatementBody();
1049 catch_or_finally_seen = true;
1050 break;
1051 }
1052 }
1053 if (!catch_or_finally_seen)
1054 Diag(atLoc, diag::err_missing_catch_finally);
1055 return 0;
1056}
Fariborz Jahanian027c23b2007-09-01 00:26:16 +00001057
Steve Naroff81f1bba2007-09-06 21:24:23 +00001058/// objc-method-def: objc-method-proto ';'[opt] '{' body '}'
Fariborz Jahanian027c23b2007-09-01 00:26:16 +00001059///
1060void Parser::ParseObjCInstanceMethodDefinition() {
1061 assert(Tok.getKind() == tok::minus &&
1062 "ParseObjCInstanceMethodDefinition(): Expected '-'");
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +00001063 // FIXME: @optional/@protocol??
Fariborz Jahanian1e4e82f2007-09-27 18:57:03 +00001064 AllImplMethods.push_back(ParseObjCMethodPrototype(ObjcImpDecl));
Fariborz Jahanian027c23b2007-09-01 00:26:16 +00001065 // parse optional ';'
1066 if (Tok.getKind() == tok::semi)
1067 ConsumeToken();
1068
1069 if (Tok.getKind() != tok::l_brace) {
1070 Diag (Tok, diag::err_expected_lbrace);
1071 return;
1072 }
1073
1074 StmtResult FnBody = ParseCompoundStatementBody();
1075}
1076
Steve Naroff81f1bba2007-09-06 21:24:23 +00001077/// objc-method-def: objc-method-proto ';'[opt] '{' body '}'
Fariborz Jahanian027c23b2007-09-01 00:26:16 +00001078///
Steve Naroff72f17fb2007-08-22 22:17:26 +00001079void Parser::ParseObjCClassMethodDefinition() {
Fariborz Jahanian027c23b2007-09-01 00:26:16 +00001080 assert(Tok.getKind() == tok::plus &&
1081 "ParseObjCClassMethodDefinition(): Expected '+'");
Fariborz Jahanian63ca8ae2007-09-17 21:07:36 +00001082 // FIXME: @optional/@protocol??
Fariborz Jahanian1e4e82f2007-09-27 18:57:03 +00001083 AllImplMethods.push_back(ParseObjCMethodPrototype(ObjcImpDecl));
Fariborz Jahanian027c23b2007-09-01 00:26:16 +00001084 // parse optional ';'
1085 if (Tok.getKind() == tok::semi)
1086 ConsumeToken();
1087 if (Tok.getKind() != tok::l_brace) {
1088 Diag (Tok, diag::err_expected_lbrace);
1089 return;
1090 }
1091
1092 StmtResult FnBody = ParseCompoundStatementBody();
Chris Lattner4b009652007-07-25 00:24:17 +00001093}
Anders Carlssona66cad42007-08-21 17:43:55 +00001094
Fariborz Jahanian37c9c612007-10-04 20:19:06 +00001095Parser::ExprResult Parser::ParseObjCExpression(SourceLocation AtLoc) {
Anders Carlssona66cad42007-08-21 17:43:55 +00001096
1097 switch (Tok.getKind()) {
1098 case tok::string_literal: // primary-expression: string-literal
1099 case tok::wide_string_literal:
Fariborz Jahanian37c9c612007-10-04 20:19:06 +00001100 return ParsePostfixExpressionSuffix(ParseObjCStringLiteral());
Anders Carlsson2996b4e2007-08-23 15:25:28 +00001101 default:
1102 break;
1103 }
1104
1105 switch (Tok.getIdentifierInfo()->getObjCKeywordID()) {
Anders Carlsson8be1d402007-08-22 15:14:15 +00001106 case tok::objc_encode:
Fariborz Jahanian37c9c612007-10-04 20:19:06 +00001107 return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression());
Anders Carlsson2996b4e2007-08-23 15:25:28 +00001108 case tok::objc_protocol:
Fariborz Jahanian37c9c612007-10-04 20:19:06 +00001109 return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression());
Anders Carlssona66cad42007-08-21 17:43:55 +00001110 default:
1111 Diag(AtLoc, diag::err_unexpected_at);
1112 SkipUntil(tok::semi);
1113 break;
1114 }
1115
1116 return 0;
1117}
1118
Fariborz Jahanian1e534dc2007-09-05 19:52:07 +00001119/// objc-message-expr:
1120/// '[' objc-receiver objc-message-args ']'
1121///
1122/// objc-receiver:
1123/// expression
1124/// class-name
1125/// type-name
1126///
1127/// objc-message-args:
1128/// objc-selector
1129/// objc-keywordarg-list
1130///
1131/// objc-keywordarg-list:
1132/// objc-keywordarg
1133/// objc-keywordarg-list objc-keywordarg
1134///
1135/// objc-keywordarg:
1136/// selector-name[opt] ':' objc-keywordexpr
1137///
1138/// objc-keywordexpr:
1139/// nonempty-expr-list
1140///
1141/// nonempty-expr-list:
1142/// assignment-expression
1143/// nonempty-expr-list , assignment-expression
1144///
1145Parser::ExprResult Parser::ParseObjCMessageExpression() {
Fariborz Jahaniand4462f92007-09-05 23:08:20 +00001146 assert(Tok.getKind() == tok::l_square && "'[' expected");
Steve Naroffc39ca262007-09-18 23:55:05 +00001147 SourceLocation LBracloc = ConsumeBracket(); // consume '['
Steve Naroff253118b2007-09-17 20:25:27 +00001148 IdentifierInfo *ReceiverName = 0;
1149 ExprTy *ReceiverExpr = 0;
Fariborz Jahaniand4462f92007-09-05 23:08:20 +00001150 // Parse receiver
Steve Narofff0c31dd2007-09-16 16:16:00 +00001151 if (Tok.getKind() == tok::identifier &&
Steve Naroff253118b2007-09-17 20:25:27 +00001152 Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope)) {
1153 ReceiverName = Tok.getIdentifierInfo();
Steve Narofff0c31dd2007-09-16 16:16:00 +00001154 ConsumeToken();
Steve Naroff253118b2007-09-17 20:25:27 +00001155 } else {
1156 ExprResult Res = ParseAssignmentExpression();
1157 if (Res.isInvalid) {
1158 SkipUntil(tok::identifier);
1159 return Res;
1160 }
1161 ReceiverExpr = Res.Val;
1162 }
Fariborz Jahaniand4462f92007-09-05 23:08:20 +00001163 // Parse objc-selector
1164 IdentifierInfo *selIdent = ParseObjCSelector();
Steve Naroff4ed9d662007-09-27 14:38:14 +00001165
1166 llvm::SmallVector<IdentifierInfo *, 12> KeyIdents;
1167 llvm::SmallVector<Action::ExprTy *, 12> KeyExprs;
1168
Fariborz Jahaniand4462f92007-09-05 23:08:20 +00001169 if (Tok.getKind() == tok::colon) {
1170 while (1) {
1171 // Each iteration parses a single keyword argument.
Steve Naroff4ed9d662007-09-27 14:38:14 +00001172 KeyIdents.push_back(selIdent);
Steve Naroff253118b2007-09-17 20:25:27 +00001173
Fariborz Jahaniand4462f92007-09-05 23:08:20 +00001174 if (Tok.getKind() != tok::colon) {
1175 Diag(Tok, diag::err_expected_colon);
1176 SkipUntil(tok::semi);
Steve Naroff253118b2007-09-17 20:25:27 +00001177 return true;
Fariborz Jahaniand4462f92007-09-05 23:08:20 +00001178 }
Steve Naroff4ed9d662007-09-27 14:38:14 +00001179 ConsumeToken(); // Eat the ':'.
Fariborz Jahaniand4462f92007-09-05 23:08:20 +00001180 /// Parse the expression after ':'
Steve Naroff253118b2007-09-17 20:25:27 +00001181 ExprResult Res = ParseAssignmentExpression();
1182 if (Res.isInvalid) {
1183 SkipUntil(tok::identifier);
1184 return Res;
1185 }
1186 // We have a valid expression.
Steve Naroff4ed9d662007-09-27 14:38:14 +00001187 KeyExprs.push_back(Res.Val);
Steve Naroff253118b2007-09-17 20:25:27 +00001188
1189 // Check for another keyword selector.
1190 selIdent = ParseObjCSelector();
1191 if (!selIdent && Tok.getKind() != tok::colon)
Fariborz Jahaniand4462f92007-09-05 23:08:20 +00001192 break;
1193 // We have a selector or a colon, continue parsing.
1194 }
1195 // Parse the, optional, argument list, comma separated.
1196 while (Tok.getKind() == tok::comma) {
1197 ConsumeToken();
1198 /// Parse the expression after ','
1199 ParseAssignmentExpression();
1200 }
1201 } else if (!selIdent) {
1202 Diag(Tok, diag::err_expected_ident); // missing selector name.
1203 SkipUntil(tok::semi);
1204 return 0;
1205 }
1206 if (Tok.getKind() != tok::r_square) {
1207 Diag(Tok, diag::err_expected_rsquare);
1208 SkipUntil(tok::semi);
1209 return 0;
1210 }
Steve Naroffc39ca262007-09-18 23:55:05 +00001211 SourceLocation RBracloc = ConsumeBracket(); // consume ']'
Steve Naroff253118b2007-09-17 20:25:27 +00001212
Steve Narofff9e80db2007-10-05 18:42:47 +00001213 unsigned nKeys = KeyIdents.size();
1214 if (nKeys) {
1215 Selector Sel = (nKeys == 1) ?
1216 PP.getSelectorTable().getUnarySelector(KeyIdents[0]) :
1217 PP.getSelectorTable().getKeywordSelector(nKeys, &KeyIdents[0]);
Steve Naroffd3f5ee42007-09-17 21:01:15 +00001218 // We've just parsed a keyword message.
1219 if (ReceiverName)
Steve Narofff9e80db2007-10-05 18:42:47 +00001220 return Actions.ActOnClassMessage(ReceiverName, Sel, LBracloc, RBracloc,
Steve Naroff4ed9d662007-09-27 14:38:14 +00001221 &KeyExprs[0]);
Steve Narofff9e80db2007-10-05 18:42:47 +00001222 return Actions.ActOnInstanceMessage(ReceiverExpr, Sel, LBracloc, RBracloc,
Steve Naroff4ed9d662007-09-27 14:38:14 +00001223 &KeyExprs[0]);
Steve Naroffd3f5ee42007-09-17 21:01:15 +00001224 }
Steve Narofff9e80db2007-10-05 18:42:47 +00001225 Selector Sel = PP.getSelectorTable().getNullarySelector(selIdent);
Steve Naroff4ed9d662007-09-27 14:38:14 +00001226
Steve Naroffd3f5ee42007-09-17 21:01:15 +00001227 // We've just parsed a unary message (a message with no arguments).
Steve Naroff253118b2007-09-17 20:25:27 +00001228 if (ReceiverName)
Steve Narofff9e80db2007-10-05 18:42:47 +00001229 return Actions.ActOnClassMessage(ReceiverName, Sel, LBracloc, RBracloc, 0);
1230 return Actions.ActOnInstanceMessage(ReceiverExpr, Sel, LBracloc, RBracloc, 0);
Fariborz Jahanian1e534dc2007-09-05 19:52:07 +00001231}
1232
Anders Carlssona66cad42007-08-21 17:43:55 +00001233Parser::ExprResult Parser::ParseObjCStringLiteral() {
1234 ExprResult Res = ParseStringLiteralExpression();
1235
1236 if (Res.isInvalid) return Res;
1237
1238 return Actions.ParseObjCStringLiteral(Res.Val);
1239}
Anders Carlsson8be1d402007-08-22 15:14:15 +00001240
1241/// objc-encode-expression:
1242/// @encode ( type-name )
1243Parser::ExprResult Parser::ParseObjCEncodeExpression() {
Steve Naroff87c329f2007-08-23 18:16:40 +00001244 assert(Tok.isObjCAtKeyword(tok::objc_encode) && "Not an @encode expression!");
Anders Carlsson8be1d402007-08-22 15:14:15 +00001245
1246 SourceLocation EncLoc = ConsumeToken();
1247
1248 if (Tok.getKind() != tok::l_paren) {
1249 Diag(Tok, diag::err_expected_lparen_after, "@encode");
1250 return true;
1251 }
1252
1253 SourceLocation LParenLoc = ConsumeParen();
1254
1255 TypeTy *Ty = ParseTypeName();
1256
Anders Carlsson92faeb82007-08-23 15:31:37 +00001257 SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
Anders Carlsson8be1d402007-08-22 15:14:15 +00001258
1259 return Actions.ParseObjCEncodeExpression(EncLoc, LParenLoc, Ty,
Anders Carlsson92faeb82007-08-23 15:31:37 +00001260 RParenLoc);
Anders Carlsson8be1d402007-08-22 15:14:15 +00001261}
Anders Carlsson2996b4e2007-08-23 15:25:28 +00001262
1263/// objc-protocol-expression
1264/// @protocol ( protocol-name )
1265
1266Parser::ExprResult Parser::ParseObjCProtocolExpression()
1267{
1268 SourceLocation ProtoLoc = ConsumeToken();
1269
1270 if (Tok.getKind() != tok::l_paren) {
1271 Diag(Tok, diag::err_expected_lparen_after, "@protocol");
1272 return true;
1273 }
1274
1275 SourceLocation LParenLoc = ConsumeParen();
1276
1277 if (Tok.getKind() != tok::identifier) {
1278 Diag(Tok, diag::err_expected_ident);
1279 return true;
1280 }
1281
1282 // FIXME: Do something with the protocol name
1283 ConsumeToken();
1284
Anders Carlsson92faeb82007-08-23 15:31:37 +00001285 SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
Anders Carlsson2996b4e2007-08-23 15:25:28 +00001286
1287 // FIXME
1288 return 0;
1289}