blob: fbb8a7369d959f9f216e580322852126810d86fe [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"
16#include "clang/Parse/DeclSpec.h"
17#include "clang/Parse/Scope.h"
18using 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.
Chris Lattnerb28317a2009-03-28 19:18:32 +000023Parser::DeclPtrTy
Douglas Gregor37b372b2009-08-20 22:52:58 +000024Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D,
25 const ParsedTemplateInfo &TemplateInfo) {
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000026 assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function &&
27 "This isn't a function declarator!");
Sebastian Redld3a413d2009-04-26 20:35:05 +000028 assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try)) &&
29 "Current token not a '{', ':' or 'try'!");
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000030
Douglas Gregor37b372b2009-08-20 22:52:58 +000031 Action::MultiTemplateParamsArg TemplateParams(Actions,
Sean Hunt4cd84942010-04-14 23:07:37 +000032 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data() : 0,
33 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
34
John McCall67d1a672009-08-06 02:15:43 +000035 DeclPtrTy FnD;
36 if (D.getDeclSpec().isFriendSpecified())
Douglas Gregor37b372b2009-08-20 22:52:58 +000037 // FIXME: Friend templates
Douglas Gregor23c94db2010-07-02 17:43:08 +000038 FnD = Actions.ActOnFriendFunctionDecl(getCurScope(), D, true,
Sean Hunt4cd84942010-04-14 23:07:37 +000039 move(TemplateParams));
Douglas Gregor37b372b2009-08-20 22:52:58 +000040 else // FIXME: pass template information through
Douglas Gregor23c94db2010-07-02 17:43:08 +000041 FnD = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS, D,
Sebastian Redld1a78462009-11-24 23:38:44 +000042 move(TemplateParams), 0, 0,
43 /*IsDefinition*/true);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000044
Eli Friedmand33133c2009-07-22 21:45:50 +000045 HandleMemberFunctionDefaultArgs(D, FnD);
46
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000047 // Consume the tokens and store them for later parsing.
48
Douglas Gregor6569d682009-05-27 23:11:45 +000049 getCurrentClass().MethodDefs.push_back(LexedMethod(FnD));
Mike Stump1eb44332009-09-09 15:08:12 +000050 getCurrentClass().MethodDefs.back().TemplateScope
Douglas Gregor23c94db2010-07-02 17:43:08 +000051 = getCurScope()->isTemplateParamScope();
Douglas Gregor6569d682009-05-27 23:11:45 +000052 CachedTokens &Toks = getCurrentClass().MethodDefs.back().Toks;
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000053
Sebastian Redld3a413d2009-04-26 20:35:05 +000054 tok::TokenKind kind = Tok.getKind();
55 // We may have a constructor initializer or function-try-block here.
56 if (kind == tok::colon || kind == tok::kw_try) {
Douglas Gregor7ad83902008-11-05 04:29:56 +000057 // Consume everything up to (and including) the left brace.
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +000058 if (!ConsumeAndStoreUntil(tok::l_brace, Toks)) {
Douglas Gregor3f08d182008-11-10 16:59:40 +000059 // We didn't find the left-brace we expected after the
Mike Stump1eb44332009-09-09 15:08:12 +000060 // constructor initializer.
Douglas Gregor3f08d182008-11-10 16:59:40 +000061 if (Tok.is(tok::semi)) {
62 // We found a semicolon; complain, consume the semicolon, and
63 // don't try to parse this method later.
64 Diag(Tok.getLocation(), diag::err_expected_lbrace);
65 ConsumeAnyToken();
Douglas Gregor6569d682009-05-27 23:11:45 +000066 getCurrentClass().MethodDefs.pop_back();
Douglas Gregor3f08d182008-11-10 16:59:40 +000067 return FnD;
68 }
69 }
70
Douglas Gregor7ad83902008-11-05 04:29:56 +000071 } else {
Mike Stump1eb44332009-09-09 15:08:12 +000072 // Begin by storing the '{' token.
Douglas Gregor7ad83902008-11-05 04:29:56 +000073 Toks.push_back(Tok);
74 ConsumeBrace();
75 }
76 // Consume everything up to (and including) the matching right brace.
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +000077 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000078
Sebastian Redld3a413d2009-04-26 20:35:05 +000079 // If we're in a function-try-block, we need to store all the catch blocks.
80 if (kind == tok::kw_try) {
81 while (Tok.is(tok::kw_catch)) {
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +000082 ConsumeAndStoreUntil(tok::l_brace, Toks, /*StopAtSemi=*/false);
83 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Sebastian Redld3a413d2009-04-26 20:35:05 +000084 }
85 }
86
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +000087 return FnD;
88}
89
Douglas Gregor72b505b2008-12-16 21:30:33 +000090/// ParseLexedMethodDeclarations - We finished parsing the member
91/// specification of a top (non-nested) C++ class. Now go over the
92/// stack of method declarations with some parts for which parsing was
93/// delayed (such as default arguments) and parse them.
Douglas Gregor6569d682009-05-27 23:11:45 +000094void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
95 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
96 ParseScope TemplateScope(this, Scope::TemplateParamScope, HasTemplateScope);
97 if (HasTemplateScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +000098 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Douglas Gregor6569d682009-05-27 23:11:45 +000099
John McCall7a1dc562009-12-19 10:49:29 +0000100 // The current scope is still active if we're the top-level class.
101 // Otherwise we'll need to push and enter a new scope.
Douglas Gregor6569d682009-05-27 23:11:45 +0000102 bool HasClassScope = !Class.TopLevelClass;
Sean Hunt4cd84942010-04-14 23:07:37 +0000103 ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope,
104 HasClassScope);
John McCall7a1dc562009-12-19 10:49:29 +0000105 if (HasClassScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000106 Actions.ActOnStartDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate);
Douglas Gregor6569d682009-05-27 23:11:45 +0000107
108 for (; !Class.MethodDecls.empty(); Class.MethodDecls.pop_front()) {
109 LateParsedMethodDeclaration &LM = Class.MethodDecls.front();
Mike Stump1eb44332009-09-09 15:08:12 +0000110
Douglas Gregord83d0402009-08-22 00:34:47 +0000111 // If this is a member template, introduce the template parameter scope.
112 ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
113 if (LM.TemplateScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000114 Actions.ActOnReenterTemplateScope(getCurScope(), LM.Method);
Mike Stump1eb44332009-09-09 15:08:12 +0000115
Douglas Gregor72b505b2008-12-16 21:30:33 +0000116 // Start the delayed C++ method declaration
Douglas Gregor23c94db2010-07-02 17:43:08 +0000117 Actions.ActOnStartDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000118
119 // Introduce the parameters into scope and parse their default
120 // arguments.
Mike Stump1eb44332009-09-09 15:08:12 +0000121 ParseScope PrototypeScope(this,
Douglas Gregor3218c4b2009-01-09 22:42:13 +0000122 Scope::FunctionPrototypeScope|Scope::DeclScope);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000123 for (unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
124 // Introduce the parameter into scope.
Douglas Gregor23c94db2010-07-02 17:43:08 +0000125 Actions.ActOnDelayedCXXMethodParameter(getCurScope(), LM.DefaultArgs[I].Param);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000126
127 if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) {
Argyrios Kyrtzidis7fd3a642010-03-30 22:14:32 +0000128 // Save the current token position.
129 SourceLocation origLoc = Tok.getLocation();
130
Douglas Gregor72b505b2008-12-16 21:30:33 +0000131 // Parse the default argument from its saved token stream.
132 Toks->push_back(Tok); // So that the current token doesn't get lost
133 PP.EnterTokenStream(&Toks->front(), Toks->size(), true, false);
134
135 // Consume the previously-pushed token.
136 ConsumeAnyToken();
137
138 // Consume the '='.
139 assert(Tok.is(tok::equal) && "Default argument not starting with '='");
140 SourceLocation EqualLoc = ConsumeToken();
141
142 OwningExprResult DefArgResult(ParseAssignmentExpression());
143 if (DefArgResult.isInvalid())
144 Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param);
Argyrios Kyrtzidis2b602ad2010-08-06 09:47:24 +0000145 else {
Argyrios Kyrtzidisf315fd62010-08-09 10:54:26 +0000146 if (Tok.is(tok::cxx_defaultarg_end))
147 ConsumeToken();
Argyrios Kyrtzidis219cffc2010-08-09 21:08:13 +0000148 else
149 Diag(Tok.getLocation(), diag::err_default_arg_unparsed);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000150 Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc,
Sebastian Redlf53597f2009-03-15 17:47:39 +0000151 move(DefArgResult));
Argyrios Kyrtzidis2b602ad2010-08-06 09:47:24 +0000152 }
Argyrios Kyrtzidis7fd3a642010-03-30 22:14:32 +0000153
154 assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
155 Tok.getLocation()) &&
156 "ParseAssignmentExpression went over the default arg tokens!");
157 // There could be leftover tokens (e.g. because of an error).
158 // Skip through until we reach the original token position.
Argyrios Kyrtzidis8f9359f2010-06-19 19:58:34 +0000159 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
Argyrios Kyrtzidis7fd3a642010-03-30 22:14:32 +0000160 ConsumeAnyToken();
161
Douglas Gregor72b505b2008-12-16 21:30:33 +0000162 delete Toks;
163 LM.DefaultArgs[I].Toks = 0;
164 }
165 }
166 PrototypeScope.Exit();
167
168 // Finish the delayed C++ method declaration.
Douglas Gregor23c94db2010-07-02 17:43:08 +0000169 Actions.ActOnFinishDelayedCXXMethodDeclaration(getCurScope(), LM.Method);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000170 }
Douglas Gregor6569d682009-05-27 23:11:45 +0000171
172 for (unsigned I = 0, N = Class.NestedClasses.size(); I != N; ++I)
173 ParseLexedMethodDeclarations(*Class.NestedClasses[I]);
John McCall7a1dc562009-12-19 10:49:29 +0000174
175 if (HasClassScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000176 Actions.ActOnFinishDelayedMemberDeclarations(getCurScope(), Class.TagOrTemplate);
Douglas Gregor72b505b2008-12-16 21:30:33 +0000177}
178
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000179/// ParseLexedMethodDefs - We finished parsing the member specification of a top
180/// (non-nested) C++ class. Now go over the stack of lexed methods that were
181/// collected during its parsing and parse them all.
Douglas Gregor6569d682009-05-27 23:11:45 +0000182void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
183 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
184 ParseScope TemplateScope(this, Scope::TemplateParamScope, HasTemplateScope);
185 if (HasTemplateScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000186 Actions.ActOnReenterTemplateScope(getCurScope(), Class.TagOrTemplate);
Douglas Gregor6569d682009-05-27 23:11:45 +0000187
188 bool HasClassScope = !Class.TopLevelClass;
189 ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope,
190 HasClassScope);
191
192 for (; !Class.MethodDefs.empty(); Class.MethodDefs.pop_front()) {
193 LexedMethod &LM = Class.MethodDefs.front();
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000194
Douglas Gregord83d0402009-08-22 00:34:47 +0000195 // If this is a member template, introduce the template parameter scope.
196 ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope);
197 if (LM.TemplateScope)
Douglas Gregor23c94db2010-07-02 17:43:08 +0000198 Actions.ActOnReenterTemplateScope(getCurScope(), LM.D);
Mike Stump1eb44332009-09-09 15:08:12 +0000199
Argyrios Kyrtzidisc50a5e02010-03-31 00:38:09 +0000200 // Save the current token position.
201 SourceLocation origLoc = Tok.getLocation();
202
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000203 assert(!LM.Toks.empty() && "Empty body!");
204 // Append the current token at the end of the new token stream so that it
205 // doesn't get lost.
206 LM.Toks.push_back(Tok);
Douglas Gregorefd5bda2009-08-24 11:57:43 +0000207 PP.EnterTokenStream(LM.Toks.data(), LM.Toks.size(), true, false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000208
209 // Consume the previously pushed token.
210 ConsumeAnyToken();
Sebastian Redld3a413d2009-04-26 20:35:05 +0000211 assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try))
212 && "Inline method not starting with '{', ':' or 'try'");
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000213
214 // Parse the method body. Function body parsing code is similar enough
215 // to be re-used for method bodies as well.
Douglas Gregor8935b8b2008-12-10 06:34:36 +0000216 ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope);
Douglas Gregor23c94db2010-07-02 17:43:08 +0000217 Actions.ActOnStartOfFunctionDef(getCurScope(), LM.D);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000218
Sebastian Redld3a413d2009-04-26 20:35:05 +0000219 if (Tok.is(tok::kw_try)) {
220 ParseFunctionTryBlock(LM.D);
Argyrios Kyrtzidisc50a5e02010-03-31 00:38:09 +0000221 assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
222 Tok.getLocation()) &&
223 "ParseFunctionTryBlock went over the cached tokens!");
Argyrios Kyrtzidis7558cd02010-06-17 10:52:22 +0000224 // There could be leftover tokens (e.g. because of an error).
225 // Skip through until we reach the original token position.
Argyrios Kyrtzidis8f9359f2010-06-19 19:58:34 +0000226 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
Argyrios Kyrtzidis7558cd02010-06-17 10:52:22 +0000227 ConsumeAnyToken();
Sebastian Redlde1b60a2009-04-26 21:08:36 +0000228 continue;
Sebastian Redld3a413d2009-04-26 20:35:05 +0000229 }
John McCalld6ca8da2010-04-10 07:37:23 +0000230 if (Tok.is(tok::colon)) {
Douglas Gregor7ad83902008-11-05 04:29:56 +0000231 ParseConstructorInitializer(LM.D);
John McCalld6ca8da2010-04-10 07:37:23 +0000232
233 // Error recovery.
234 if (!Tok.is(tok::l_brace)) {
235 Actions.ActOnFinishFunctionBody(LM.D, Action::StmtArg(Actions));
236 continue;
237 }
238 } else
Fariborz Jahanian393612e2009-07-21 22:36:06 +0000239 Actions.ActOnDefaultCtorInitializers(LM.D);
Fariborz Jahaniand01c9152009-07-14 18:24:21 +0000240
Chris Lattner40e9bc82009-03-05 00:49:17 +0000241 ParseFunctionStatementBody(LM.D);
Ted Kremenek252485e2010-06-17 00:59:17 +0000242
Argyrios Kyrtzidis7558cd02010-06-17 10:52:22 +0000243 if (Tok.getLocation() != origLoc) {
244 // Due to parsing error, we either went over the cached tokens or
245 // there are still cached tokens left. If it's the latter case skip the
246 // leftover tokens.
247 // Since this is an uncommon situation that should be avoided, use the
248 // expensive isBeforeInTranslationUnit call.
249 if (PP.getSourceManager().isBeforeInTranslationUnit(Tok.getLocation(),
250 origLoc))
Argyrios Kyrtzidis8f9359f2010-06-19 19:58:34 +0000251 while (Tok.getLocation() != origLoc && Tok.isNot(tok::eof))
Argyrios Kyrtzidis7558cd02010-06-17 10:52:22 +0000252 ConsumeAnyToken();
253
254 }
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000255 }
Douglas Gregor6569d682009-05-27 23:11:45 +0000256
257 for (unsigned I = 0, N = Class.NestedClasses.size(); I != N; ++I)
258 ParseLexedMethodDefs(*Class.NestedClasses[I]);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000259}
260
261/// ConsumeAndStoreUntil - Consume and store the token at the passed token
Douglas Gregor72b505b2008-12-16 21:30:33 +0000262/// container until the token 'T' is reached (which gets
Mike Stump1eb44332009-09-09 15:08:12 +0000263/// consumed/stored too, if ConsumeFinalToken).
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000264/// If StopAtSemi is true, then we will stop early at a ';' character.
Douglas Gregor72b505b2008-12-16 21:30:33 +0000265/// Returns true if token 'T1' or 'T2' was found.
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000266/// NOTE: This is a specialized version of Parser::SkipUntil.
Douglas Gregor72b505b2008-12-16 21:30:33 +0000267bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
268 CachedTokens &Toks,
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000269 bool StopAtSemi, bool ConsumeFinalToken) {
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000270 // We always want this function to consume at least one token if the first
271 // token isn't T and if not at EOF.
272 bool isFirstTokenConsumed = true;
273 while (1) {
274 // If we found one of the tokens, stop and return true.
Douglas Gregor72b505b2008-12-16 21:30:33 +0000275 if (Tok.is(T1) || Tok.is(T2)) {
276 if (ConsumeFinalToken) {
277 Toks.push_back(Tok);
278 ConsumeAnyToken();
279 }
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000280 return true;
281 }
282
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000283 switch (Tok.getKind()) {
284 case tok::eof:
285 // Ran out of tokens.
286 return false;
287
288 case tok::l_paren:
289 // Recursively consume properly-nested parens.
290 Toks.push_back(Tok);
291 ConsumeParen();
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000292 ConsumeAndStoreUntil(tok::r_paren, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000293 break;
294 case tok::l_square:
295 // Recursively consume properly-nested square brackets.
296 Toks.push_back(Tok);
297 ConsumeBracket();
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000298 ConsumeAndStoreUntil(tok::r_square, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000299 break;
300 case tok::l_brace:
301 // Recursively consume properly-nested braces.
302 Toks.push_back(Tok);
303 ConsumeBrace();
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000304 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000305 break;
306
307 // Okay, we found a ']' or '}' or ')', which we think should be balanced.
308 // Since the user wasn't looking for this token (if they were, it would
309 // already be handled), this isn't balanced. If there is a LHS token at a
310 // higher level, we will assume that this matches the unbalanced token
311 // and return it. Otherwise, this is a spurious RHS token, which we skip.
312 case tok::r_paren:
313 if (ParenCount && !isFirstTokenConsumed)
314 return false; // Matches something.
315 Toks.push_back(Tok);
316 ConsumeParen();
317 break;
318 case tok::r_square:
319 if (BracketCount && !isFirstTokenConsumed)
320 return false; // Matches something.
321 Toks.push_back(Tok);
322 ConsumeBracket();
323 break;
324 case tok::r_brace:
325 if (BraceCount && !isFirstTokenConsumed)
326 return false; // Matches something.
327 Toks.push_back(Tok);
328 ConsumeBrace();
329 break;
330
331 case tok::string_literal:
332 case tok::wide_string_literal:
333 Toks.push_back(Tok);
334 ConsumeStringToken();
335 break;
Argyrios Kyrtzidis14b91622010-04-23 21:20:12 +0000336 case tok::semi:
337 if (StopAtSemi)
338 return false;
339 // FALL THROUGH.
Argyrios Kyrtzidis4cc18a42008-06-24 22:12:16 +0000340 default:
341 // consume this token.
342 Toks.push_back(Tok);
343 ConsumeToken();
344 break;
345 }
346 isFirstTokenConsumed = false;
347 }
348}