blob: 61c4d3ebba3bfd4262001634960aa5c8437a2c91 [file] [log] [blame]
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +00001//===--- ParseCXXInlineMethods.cpp - C++ class inline methods parsing------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements parsing for C++ class inline methods.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattner500d3292009-01-29 05:15:15 +000014#include "clang/Parse/ParseDiagnostic.h"
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000015#include "clang/Parse/Parser.h"
John McCall19510852010-08-20 18:27:03 +000016#include "clang/Sema/DeclSpec.h"
17#include "clang/Sema/Scope.h"
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000018using namespace clang;
19
Sebastian Redld3a413d2009-04-26 20:35:05 +000020/// ParseCXXInlineMethodDef - We parsed and verified that the specified
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000021/// Declarator is a well formed C++ inline method definition. Now lex its body
22/// and store its tokens for parsing after the C++ class is complete.
John McCalld226f652010-08-21 09:40:31 +000023Decl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
Douglas Gregor37b372b2009-08-20 22:52:58 +000024 const ParsedTemplateInfo &TemplateInfo) {
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000025 assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&
26 "This isn't a function declarator!");
Sebastian Redld3a413d2009-04-26 20:35:05 +000027 assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try)) &&
28 "Current token not a '{', ':' or 'try'!");
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000029
Douglas Gregor37b372b2009-08-20 22:52:58 +000030 Action::MultiTemplateParamsArg TemplateParams(Actions,
Sean Hunt4cd84942010-04-14 23:07:37 +000031 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data() : 0,
32 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
33
John McCalld226f652010-08-21 09:40:31 +000034 Decl *FnD;
John McCall67d1a672009-08-06 02:15:43 +000035 if (D.getDeclSpec().isFriendSpecified())
Douglas Gregor37b372b2009-08-20 22:52:58 +000036 // FIXME: Friend templates
Douglas Gregor23c94db2010-07-02 17:43:08 +000037 FnD = Actions.ActOnFriendFunctionDecl(getCurScope(), D, true,
Sean Hunt4cd84942010-04-14 23:07:37 +000038 move(TemplateParams));
Douglas Gregor37b372b2009-08-20 22:52:58 +000039 else // FIXME: pass template information through
Douglas Gregor23c94db2010-07-02 17:43:08 +000040 FnD = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS, D,
Sebastian Redld1a78462009-11-24 23:38:44 +000041 move(TemplateParams), 0, 0,
42 /*IsDefinition*/true);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000043
Eli Friedmand33133c2009-07-22 21:45:50 +000044 HandleMemberFunctionDefaultArgs(D, FnD);
45
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000046 // Consume the tokens and store them for later parsing.
47
Douglas Gregor6569d682009-05-27 23:11:45 +000048 getCurrentClass().MethodDefs.push_back(LexedMethod(FnD));
Mike Stump1eb44332009-09-09 15:08:12 +000049 getCurrentClass().MethodDefs.back().TemplateScope
Douglas Gregor23c94db2010-07-02 17:43:08 +000050 = getCurScope()->isTemplateParamScope();
Douglas Gregor6569d682009-05-27 23:11:45 +000051 CachedTokens &Toks = getCurrentClass().MethodDefs.back().Toks;
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000052
Sebastian Redld3a413d2009-04-26 20:35:05 +000053 tok::TokenKind kind = Tok.getKind();
54 // We may have a constructor initializer or function-try-block here.
55 if (kind == tok::colon || kind == tok::kw_try) {
Douglas Gregor7ad83902008-11-05 04:29:56 +000056 // Consume everything up to (and including) the left brace.
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +000057 if (!ConsumeAndStoreUntil(tok::l_brace, Toks)) {
Douglas Gregor3f08d182008-11-10 16:59:40 +000058 // We didn't find the left-brace we expected after the
Mike Stump1eb44332009-09-09 15:08:12 +000059 // constructor initializer.
Douglas Gregor3f08d182008-11-10 16:59:40 +000060 if (Tok.is(tok::semi)) {
61 // We found a semicolon; complain, consume the semicolon, and
62 // don't try to parse this method later.
63 Diag(Tok.getLocation(), diag::err_expected_lbrace);
64 ConsumeAnyToken();
Douglas Gregor6569d682009-05-27 23:11:45 +000065 getCurrentClass().MethodDefs.pop_back();
Douglas Gregor3f08d182008-11-10 16:59:40 +000066 return FnD;
67 }
68 }
69
Douglas Gregor7ad83902008-11-05 04:29:56 +000070 } else {
Mike Stump1eb44332009-09-09 15:08:12 +000071 // Begin by storing the '{' token.
Douglas Gregor7ad83902008-11-05 04:29:56 +000072 Toks.push_back(Tok);
73 ConsumeBrace();
74 }
75 // Consume everything up to (and including) the matching right brace.
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +000076 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000077
Sebastian Redld3a413d2009-04-26 20:35:05 +000078 // If we're in a function-try-block, we need to store all the catch blocks.
79 if (kind == tok::kw_try) {
80 while (Tok.is(tok::kw_catch)) {
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +000081 ConsumeAndStoreUntil(tok::l_brace, Toks, /*StopAtSemi=*/false);
82 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Sebastian Redld3a413d2009-04-26 20:35:05 +000083 }
84 }
85
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000086 return FnD;
87}
88
Douglas Gregor72b505b2008-12-16 21:30:33 +000089/// ParseLexedMethodDeclarations - We finished parsing the member
90/// specification of a top (non-nested) C++ class. Now go over the
91/// stack of method declarations with some parts for which parsing was
92/// delayed (such as default arguments) and parse them.
Douglas Gregor6569d682009-05-27 23:11:45 +000093void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
94 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
95 ParseScope TemplateScope(this, Scope::TemplateParamScope, HasTemplateScope);
96 if (HasTemplateScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +000097 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Douglas Gregor6569d682009-05-27 23:11:45 +000098
John McCall7a1dc562009-12-19 10:49:29 +000099 // The current scope is still active if we're the top-level class.
100 // Otherwise we'll need to push and enter a new scope.
Douglas Gregor6569d682009-05-27 23:11:45 +0000101 bool HasClassScope = !Class.TopLevelClass;
Sean Hunt4cd84942010-04-14 23:07:37 +0000102 ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope,
103 HasClassScope);
John McCall7a1dc562009-12-19 10:49:29 +0000104 if (HasClassScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000105 Actions.ActOnStartDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate);
Douglas Gregor6569d682009-05-27 23:11:45 +0000106
107 for (; !Class.MethodDecls.empty(); Class.MethodDecls.pop_front()) {
108 LateParsedMethodDeclaration &LM = Class.MethodDecls.front();
Mike Stump1eb44332009-09-09 15:08:12 +0000109
Douglas Gregord83d0402009-08-22 00:34:47 +0000110 // If this is a member template, introduce the template parameter scope.
111 ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
112 if (LM.TemplateScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000113 Actions.ActOnReenterTemplateScope(getCurScope(), LM.Method);
Mike Stump1eb44332009-09-09 15:08:12 +0000114
Douglas Gregor72b505b2008-12-16 21:30:33 +0000115 // Start the delayed C++ method declaration
Douglas Gregor23c94db2010-07-02 17:43:08 +0000116 Actions.ActOnStartDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000117
118 // Introduce the parameters into scope and parse their default
119 // arguments.
Mike Stump1eb44332009-09-09 15:08:12 +0000120 ParseScope PrototypeScope(this,
Douglas Gregor3218c4b2009-01-09 22:42:13 +0000121 Scope::FunctionPrototypeScope|Scope::DeclScope);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000122 for (unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
123 // Introduce the parameter into scope.
Douglas Gregor23c94db2010-07-02 17:43:08 +0000124 Actions.ActOnDelayedCXXMethodParameter(getCurScope(), LM.DefaultArgs[I].Param);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000125
126 if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
Argyrios Kyrtzidis7fd3a642010-03-30 22:14:32 +0000127 // Save the current token position.
128 SourceLocation origLoc = Tok.getLocation();
129
Douglas Gregor72b505b2008-12-16 21:30:33 +0000130 // Parse the default argument from its saved token stream.
131 Toks->push_back(Tok); // So that the current token doesn't get lost
132 PP.EnterTokenStream(&Toks->front(), Toks->size(), true, false);
133
134 // Consume the previously-pushed token.
135 ConsumeAnyToken();
136
137 // Consume the '='.
138 assert(Tok.is(tok::equal) && "Default argument not starting with '='");
139 SourceLocation EqualLoc = ConsumeToken();
140
John McCall60d7b3a2010-08-24 06:29:42 +0000141 ExprResult DefArgResult(ParseAssignmentExpression());
Douglas Gregor72b505b2008-12-16 21:30:33 +0000142 if (DefArgResult.isInvalid())
143 Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param);
Argyrios Kyrtzidis2b602ad2010-08-06 09:47:24 +0000144 else {
Argyrios Kyrtzidisf315fd62010-08-09 10:54:26 +0000145 if (Tok.is(tok::cxx_defaultarg_end))
146 ConsumeToken();
Argyrios Kyrtzidis219cffc2010-08-09 21:08:13 +0000147 else
148 Diag(Tok.getLocation(), diag::err_default_arg_unparsed);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000149 Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc,
John McCall9ae2f072010-08-23 23:25:46 +0000150 DefArgResult.take());
Argyrios Kyrtzidis2b602ad2010-08-06 09:47:24 +0000151 }
Argyrios Kyrtzidis7fd3a642010-03-30 22:14:32 +0000152
153 assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
154 Tok.getLocation()) &&
155 "ParseAssignmentExpression went over the default arg tokens!");
156 // There could be leftover tokens (e.g. because of an error).
157 // Skip through until we reach the original token position.
Argyrios Kyrtzidis8f9359f2010-06-19 19:58:34 +0000158 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
Argyrios Kyrtzidis7fd3a642010-03-30 22:14:32 +0000159 ConsumeAnyToken();
160
Douglas Gregor72b505b2008-12-16 21:30:33 +0000161 delete Toks;
162 LM.DefaultArgs[I].Toks = 0;
163 }
164 }
165 PrototypeScope.Exit();
166
167 // Finish the delayed C++ method declaration.
Douglas Gregor23c94db2010-07-02 17:43:08 +0000168 Actions.ActOnFinishDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000169 }
Douglas Gregor6569d682009-05-27 23:11:45 +0000170
171 for (unsigned I = 0, N = Class.NestedClasses.size(); I != N; ++I)
172 ParseLexedMethodDeclarations(*Class.NestedClasses[I]);
John McCall7a1dc562009-12-19 10:49:29 +0000173
174 if (HasClassScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000175 Actions.ActOnFinishDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000176}
177
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000178/// ParseLexedMethodDefs - We finished parsing the member specification of a top
179/// (non-nested) C++ class. Now go over the stack of lexed methods that were
180/// collected during its parsing and parse them all.
Douglas Gregor6569d682009-05-27 23:11:45 +0000181void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
182 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
183 ParseScope TemplateScope(this, Scope::TemplateParamScope, HasTemplateScope);
184 if (HasTemplateScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000185 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Douglas Gregor6569d682009-05-27 23:11:45 +0000186
187 bool HasClassScope = !Class.TopLevelClass;
188 ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope,
189 HasClassScope);
190
191 for (; !Class.MethodDefs.empty(); Class.MethodDefs.pop_front()) {
192 LexedMethod &LM = Class.MethodDefs.front();
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000193
Douglas Gregord83d0402009-08-22 00:34:47 +0000194 // If this is a member template, introduce the template parameter scope.
195 ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
196 if (LM.TemplateScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000197 Actions.ActOnReenterTemplateScope(getCurScope(), LM.D);
Mike Stump1eb44332009-09-09 15:08:12 +0000198
Argyrios Kyrtzidisc50a5e02010-03-31 00:38:09 +0000199 // Save the current token position.
200 SourceLocation origLoc = Tok.getLocation();
201
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000202 assert(!LM.Toks.empty() && "Empty body!");
203 // Append the current token at the end of the new token stream so that it
204 // doesn't get lost.
205 LM.Toks.push_back(Tok);
Douglas Gregorefd5bda2009-08-24 11:57:43 +0000206 PP.EnterTokenStream(LM.Toks.data(), LM.Toks.size(), true, false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000207
208 // Consume the previously pushed token.
209 ConsumeAnyToken();
Sebastian Redld3a413d2009-04-26 20:35:05 +0000210 assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try))
211 && "Inline method not starting with '{', ':' or 'try'");
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000212
213 // Parse the method body. Function body parsing code is similar enough
214 // to be re-used for method bodies as well.
Douglas Gregor8935b8b2008-12-10 06:34:36 +0000215 ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope);
Douglas Gregor23c94db2010-07-02 17:43:08 +0000216 Actions.ActOnStartOfFunctionDef(getCurScope(), LM.D);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000217
Sebastian Redld3a413d2009-04-26 20:35:05 +0000218 if (Tok.is(tok::kw_try)) {
219 ParseFunctionTryBlock(LM.D);
Argyrios Kyrtzidisc50a5e02010-03-31 00:38:09 +0000220 assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
221 Tok.getLocation()) &&
222 "ParseFunctionTryBlock went over the cached tokens!");
Argyrios Kyrtzidis7558cd02010-06-17 10:52:22 +0000223 // There could be leftover tokens (e.g. because of an error).
224 // Skip through until we reach the original token position.
Argyrios Kyrtzidis8f9359f2010-06-19 19:58:34 +0000225 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
Argyrios Kyrtzidis7558cd02010-06-17 10:52:22 +0000226 ConsumeAnyToken();
Sebastian Redlde1b60a2009-04-26 21:08:36 +0000227 continue;
Sebastian Redld3a413d2009-04-26 20:35:05 +0000228 }
John McCalld6ca8da2010-04-10 07:37:23 +0000229 if (Tok.is(tok::colon)) {
Douglas Gregor7ad83902008-11-05 04:29:56 +0000230 ParseConstructorInitializer(LM.D);
John McCalld6ca8da2010-04-10 07:37:23 +0000231
232 // Error recovery.
233 if (!Tok.is(tok::l_brace)) {
John McCall9ae2f072010-08-23 23:25:46 +0000234 Actions.ActOnFinishFunctionBody(LM.D, 0);
John McCalld6ca8da2010-04-10 07:37:23 +0000235 continue;
236 }
237 } else
Fariborz Jahanian393612e2009-07-21 22:36:06 +0000238 Actions.ActOnDefaultCtorInitializers(LM.D);
Fariborz Jahaniand01c9152009-07-14 18:24:21 +0000239
Chris Lattner40e9bc82009-03-05 00:49:17 +0000240 ParseFunctionStatementBody(LM.D);
Ted Kremenek252485e2010-06-17 00:59:17 +0000241
Argyrios Kyrtzidis7558cd02010-06-17 10:52:22 +0000242 if (Tok.getLocation() != origLoc) {
243 // Due to parsing error, we either went over the cached tokens or
244 // there are still cached tokens left. If it's the latter case skip the
245 // leftover tokens.
246 // Since this is an uncommon situation that should be avoided, use the
247 // expensive isBeforeInTranslationUnit call.
248 if (PP.getSourceManager().isBeforeInTranslationUnit(Tok.getLocation(),
249 origLoc))
Argyrios Kyrtzidis8f9359f2010-06-19 19:58:34 +0000250 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
Argyrios Kyrtzidis7558cd02010-06-17 10:52:22 +0000251 ConsumeAnyToken();
252
253 }
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000254 }
Douglas Gregor6569d682009-05-27 23:11:45 +0000255
256 for (unsigned I = 0, N = Class.NestedClasses.size(); I != N; ++I)
257 ParseLexedMethodDefs(*Class.NestedClasses[I]);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000258}
259
260/// ConsumeAndStoreUntil - Consume and store the token at the passed token
Douglas Gregor72b505b2008-12-16 21:30:33 +0000261/// container until the token 'T' is reached (which gets
Mike Stump1eb44332009-09-09 15:08:12 +0000262/// consumed/stored too, if ConsumeFinalToken).
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000263/// If StopAtSemi is true, then we will stop early at a ';' character.
Douglas Gregor72b505b2008-12-16 21:30:33 +0000264/// Returns true if token 'T1' or 'T2' was found.
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000265/// NOTE: This is a specialized version of Parser::SkipUntil.
Douglas Gregor72b505b2008-12-16 21:30:33 +0000266bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
267 CachedTokens &Toks,
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000268 bool StopAtSemi, bool ConsumeFinalToken) {
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000269 // We always want this function to consume at least one token if the first
270 // token isn't T and if not at EOF.
271 bool isFirstTokenConsumed = true;
272 while (1) {
273 // If we found one of the tokens, stop and return true.
Douglas Gregor72b505b2008-12-16 21:30:33 +0000274 if (Tok.is(T1) || Tok.is(T2)) {
275 if (ConsumeFinalToken) {
276 Toks.push_back(Tok);
277 ConsumeAnyToken();
278 }
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000279 return true;
280 }
281
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000282 switch (Tok.getKind()) {
283 case tok::eof:
284 // Ran out of tokens.
285 return false;
286
287 case tok::l_paren:
288 // Recursively consume properly-nested parens.
289 Toks.push_back(Tok);
290 ConsumeParen();
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000291 ConsumeAndStoreUntil(tok::r_paren, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000292 break;
293 case tok::l_square:
294 // Recursively consume properly-nested square brackets.
295 Toks.push_back(Tok);
296 ConsumeBracket();
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000297 ConsumeAndStoreUntil(tok::r_square, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000298 break;
299 case tok::l_brace:
300 // Recursively consume properly-nested braces.
301 Toks.push_back(Tok);
302 ConsumeBrace();
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000303 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000304 break;
305
306 // Okay, we found a ']' or '}' or ')', which we think should be balanced.
307 // Since the user wasn't looking for this token (if they were, it would
308 // already be handled), this isn't balanced. If there is a LHS token at a
309 // higher level, we will assume that this matches the unbalanced token
310 // and return it. Otherwise, this is a spurious RHS token, which we skip.
311 case tok::r_paren:
312 if (ParenCount && !isFirstTokenConsumed)
313 return false; // Matches something.
314 Toks.push_back(Tok);
315 ConsumeParen();
316 break;
317 case tok::r_square:
318 if (BracketCount && !isFirstTokenConsumed)
319 return false; // Matches something.
320 Toks.push_back(Tok);
321 ConsumeBracket();
322 break;
323 case tok::r_brace:
324 if (BraceCount && !isFirstTokenConsumed)
325 return false; // Matches something.
326 Toks.push_back(Tok);
327 ConsumeBrace();
328 break;
329
330 case tok::string_literal:
331 case tok::wide_string_literal:
332 Toks.push_back(Tok);
333 ConsumeStringToken();
334 break;
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000335 case tok::semi:
336 if (StopAtSemi)
337 return false;
338 // FALL THROUGH.
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000339 default:
340 // consume this token.
341 Toks.push_back(Tok);
342 ConsumeToken();
343 break;
344 }
345 isFirstTokenConsumed = false;
346 }
347}