Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 1 | //===--- 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 Lattner | 500d329 | 2009-01-29 05:15:15 +0000 | [diff] [blame] | 14 | #include "clang/Parse/ParseDiagnostic.h" |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 15 | #include "clang/Parse/Parser.h" |
| 16 | #include "clang/Parse/DeclSpec.h" |
| 17 | #include "clang/Parse/Scope.h" |
| 18 | using namespace clang; |
| 19 | |
Sebastian Redl | d3a413d | 2009-04-26 20:35:05 +0000 | [diff] [blame] | 20 | /// ParseCXXInlineMethodDef - We parsed and verified that the specified |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 21 | /// 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 Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 23 | Parser::DeclPtrTy |
Douglas Gregor | 37b372b | 2009-08-20 22:52:58 +0000 | [diff] [blame] | 24 | Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, Declarator &D, |
| 25 | const ParsedTemplateInfo &TemplateInfo) { |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 26 | assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function && |
| 27 | "This isn't a function declarator!"); |
Sebastian Redl | d3a413d | 2009-04-26 20:35:05 +0000 | [diff] [blame] | 28 | assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try)) && |
| 29 | "Current token not a '{', ':' or 'try'!"); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 30 | |
Douglas Gregor | 37b372b | 2009-08-20 22:52:58 +0000 | [diff] [blame] | 31 | Action::MultiTemplateParamsArg TemplateParams(Actions, |
| 32 | TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data() : 0, |
| 33 | TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->size() : 0); |
John McCall | 67d1a67 | 2009-08-06 02:15:43 +0000 | [diff] [blame] | 34 | DeclPtrTy FnD; |
| 35 | if (D.getDeclSpec().isFriendSpecified()) |
Douglas Gregor | 37b372b | 2009-08-20 22:52:58 +0000 | [diff] [blame] | 36 | // FIXME: Friend templates |
John McCall | bbbcdd9 | 2009-09-11 21:02:39 +0000 | [diff] [blame] | 37 | FnD = Actions.ActOnFriendFunctionDecl(CurScope, D, true, move(TemplateParams)); |
Douglas Gregor | 37b372b | 2009-08-20 22:52:58 +0000 | [diff] [blame] | 38 | else // FIXME: pass template information through |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 39 | FnD = Actions.ActOnCXXMemberDeclarator(CurScope, AS, D, |
Douglas Gregor | 37b372b | 2009-08-20 22:52:58 +0000 | [diff] [blame] | 40 | move(TemplateParams), 0, 0); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 41 | |
Eli Friedman | d33133c | 2009-07-22 21:45:50 +0000 | [diff] [blame] | 42 | HandleMemberFunctionDefaultArgs(D, FnD); |
| 43 | |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 44 | // Consume the tokens and store them for later parsing. |
| 45 | |
Douglas Gregor | 6569d68 | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 46 | getCurrentClass().MethodDefs.push_back(LexedMethod(FnD)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 47 | getCurrentClass().MethodDefs.back().TemplateScope |
Douglas Gregor | d83d040 | 2009-08-22 00:34:47 +0000 | [diff] [blame] | 48 | = CurScope->isTemplateParamScope(); |
Douglas Gregor | 6569d68 | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 49 | CachedTokens &Toks = getCurrentClass().MethodDefs.back().Toks; |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 50 | |
Sebastian Redl | d3a413d | 2009-04-26 20:35:05 +0000 | [diff] [blame] | 51 | tok::TokenKind kind = Tok.getKind(); |
| 52 | // We may have a constructor initializer or function-try-block here. |
| 53 | if (kind == tok::colon || kind == tok::kw_try) { |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 54 | // Consume everything up to (and including) the left brace. |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 55 | if (!ConsumeAndStoreUntil(tok::l_brace, tok::unknown, Toks, tok::semi)) { |
Douglas Gregor | 3f08d18 | 2008-11-10 16:59:40 +0000 | [diff] [blame] | 56 | // We didn't find the left-brace we expected after the |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 57 | // constructor initializer. |
Douglas Gregor | 3f08d18 | 2008-11-10 16:59:40 +0000 | [diff] [blame] | 58 | if (Tok.is(tok::semi)) { |
| 59 | // We found a semicolon; complain, consume the semicolon, and |
| 60 | // don't try to parse this method later. |
| 61 | Diag(Tok.getLocation(), diag::err_expected_lbrace); |
| 62 | ConsumeAnyToken(); |
Douglas Gregor | 6569d68 | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 63 | getCurrentClass().MethodDefs.pop_back(); |
Douglas Gregor | 3f08d18 | 2008-11-10 16:59:40 +0000 | [diff] [blame] | 64 | return FnD; |
| 65 | } |
| 66 | } |
| 67 | |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 68 | } else { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 69 | // Begin by storing the '{' token. |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 70 | Toks.push_back(Tok); |
| 71 | ConsumeBrace(); |
| 72 | } |
| 73 | // Consume everything up to (and including) the matching right brace. |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 74 | ConsumeAndStoreUntil(tok::r_brace, tok::unknown, Toks); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 75 | |
Sebastian Redl | d3a413d | 2009-04-26 20:35:05 +0000 | [diff] [blame] | 76 | // If we're in a function-try-block, we need to store all the catch blocks. |
| 77 | if (kind == tok::kw_try) { |
| 78 | while (Tok.is(tok::kw_catch)) { |
| 79 | ConsumeAndStoreUntil(tok::l_brace, tok::unknown, Toks); |
| 80 | ConsumeAndStoreUntil(tok::r_brace, tok::unknown, Toks); |
| 81 | } |
| 82 | } |
| 83 | |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 84 | return FnD; |
| 85 | } |
| 86 | |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 87 | /// ParseLexedMethodDeclarations - We finished parsing the member |
| 88 | /// specification of a top (non-nested) C++ class. Now go over the |
| 89 | /// stack of method declarations with some parts for which parsing was |
| 90 | /// delayed (such as default arguments) and parse them. |
Douglas Gregor | 6569d68 | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 91 | void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) { |
| 92 | bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope; |
| 93 | ParseScope TemplateScope(this, Scope::TemplateParamScope, HasTemplateScope); |
| 94 | if (HasTemplateScope) |
| 95 | Actions.ActOnReenterTemplateScope(CurScope, Class.TagOrTemplate); |
| 96 | |
| 97 | bool HasClassScope = !Class.TopLevelClass; |
| 98 | ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope, |
| 99 | HasClassScope); |
| 100 | |
| 101 | for (; !Class.MethodDecls.empty(); Class.MethodDecls.pop_front()) { |
| 102 | LateParsedMethodDeclaration &LM = Class.MethodDecls.front(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 103 | |
Douglas Gregor | d83d040 | 2009-08-22 00:34:47 +0000 | [diff] [blame] | 104 | // If this is a member template, introduce the template parameter scope. |
| 105 | ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope); |
| 106 | if (LM.TemplateScope) |
| 107 | Actions.ActOnReenterTemplateScope(CurScope, LM.Method); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 108 | |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 109 | // Start the delayed C++ method declaration |
| 110 | Actions.ActOnStartDelayedCXXMethodDeclaration(CurScope, LM.Method); |
| 111 | |
| 112 | // Introduce the parameters into scope and parse their default |
| 113 | // arguments. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 114 | ParseScope PrototypeScope(this, |
Douglas Gregor | 3218c4b | 2009-01-09 22:42:13 +0000 | [diff] [blame] | 115 | Scope::FunctionPrototypeScope|Scope::DeclScope); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 116 | for (unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) { |
| 117 | // Introduce the parameter into scope. |
| 118 | Actions.ActOnDelayedCXXMethodParameter(CurScope, LM.DefaultArgs[I].Param); |
| 119 | |
| 120 | if (CachedTokens *Toks = LM.DefaultArgs[I].Toks) { |
| 121 | // Parse the default argument from its saved token stream. |
| 122 | Toks->push_back(Tok); // So that the current token doesn't get lost |
| 123 | PP.EnterTokenStream(&Toks->front(), Toks->size(), true, false); |
| 124 | |
| 125 | // Consume the previously-pushed token. |
| 126 | ConsumeAnyToken(); |
| 127 | |
| 128 | // Consume the '='. |
| 129 | assert(Tok.is(tok::equal) && "Default argument not starting with '='"); |
| 130 | SourceLocation EqualLoc = ConsumeToken(); |
| 131 | |
| 132 | OwningExprResult DefArgResult(ParseAssignmentExpression()); |
| 133 | if (DefArgResult.isInvalid()) |
| 134 | Actions.ActOnParamDefaultArgumentError(LM.DefaultArgs[I].Param); |
| 135 | else |
| 136 | Actions.ActOnParamDefaultArgument(LM.DefaultArgs[I].Param, EqualLoc, |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 137 | move(DefArgResult)); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 138 | delete Toks; |
| 139 | LM.DefaultArgs[I].Toks = 0; |
| 140 | } |
| 141 | } |
| 142 | PrototypeScope.Exit(); |
| 143 | |
| 144 | // Finish the delayed C++ method declaration. |
| 145 | Actions.ActOnFinishDelayedCXXMethodDeclaration(CurScope, LM.Method); |
| 146 | } |
Douglas Gregor | 6569d68 | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 147 | |
| 148 | for (unsigned I = 0, N = Class.NestedClasses.size(); I != N; ++I) |
| 149 | ParseLexedMethodDeclarations(*Class.NestedClasses[I]); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 152 | /// ParseLexedMethodDefs - We finished parsing the member specification of a top |
| 153 | /// (non-nested) C++ class. Now go over the stack of lexed methods that were |
| 154 | /// collected during its parsing and parse them all. |
Douglas Gregor | 6569d68 | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 155 | void Parser::ParseLexedMethodDefs(ParsingClass &Class) { |
| 156 | bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope; |
| 157 | ParseScope TemplateScope(this, Scope::TemplateParamScope, HasTemplateScope); |
| 158 | if (HasTemplateScope) |
| 159 | Actions.ActOnReenterTemplateScope(CurScope, Class.TagOrTemplate); |
| 160 | |
| 161 | bool HasClassScope = !Class.TopLevelClass; |
| 162 | ParseScope ClassScope(this, Scope::ClassScope|Scope::DeclScope, |
| 163 | HasClassScope); |
| 164 | |
| 165 | for (; !Class.MethodDefs.empty(); Class.MethodDefs.pop_front()) { |
| 166 | LexedMethod &LM = Class.MethodDefs.front(); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 167 | |
Douglas Gregor | d83d040 | 2009-08-22 00:34:47 +0000 | [diff] [blame] | 168 | // If this is a member template, introduce the template parameter scope. |
| 169 | ParseScope TemplateScope(this, Scope::TemplateParamScope, LM.TemplateScope); |
| 170 | if (LM.TemplateScope) |
| 171 | Actions.ActOnReenterTemplateScope(CurScope, LM.D); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 172 | |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 173 | assert(!LM.Toks.empty() && "Empty body!"); |
| 174 | // Append the current token at the end of the new token stream so that it |
| 175 | // doesn't get lost. |
| 176 | LM.Toks.push_back(Tok); |
Douglas Gregor | efd5bda | 2009-08-24 11:57:43 +0000 | [diff] [blame] | 177 | PP.EnterTokenStream(LM.Toks.data(), LM.Toks.size(), true, false); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 178 | |
| 179 | // Consume the previously pushed token. |
| 180 | ConsumeAnyToken(); |
Sebastian Redl | d3a413d | 2009-04-26 20:35:05 +0000 | [diff] [blame] | 181 | assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try)) |
| 182 | && "Inline method not starting with '{', ':' or 'try'"); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 183 | |
| 184 | // Parse the method body. Function body parsing code is similar enough |
| 185 | // to be re-used for method bodies as well. |
Douglas Gregor | 8935b8b | 2008-12-10 06:34:36 +0000 | [diff] [blame] | 186 | ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 187 | Actions.ActOnStartOfFunctionDef(CurScope, LM.D); |
| 188 | |
Sebastian Redl | d3a413d | 2009-04-26 20:35:05 +0000 | [diff] [blame] | 189 | if (Tok.is(tok::kw_try)) { |
| 190 | ParseFunctionTryBlock(LM.D); |
Sebastian Redl | de1b60a | 2009-04-26 21:08:36 +0000 | [diff] [blame] | 191 | continue; |
Sebastian Redl | d3a413d | 2009-04-26 20:35:05 +0000 | [diff] [blame] | 192 | } |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 193 | if (Tok.is(tok::colon)) |
| 194 | ParseConstructorInitializer(LM.D); |
Fariborz Jahanian | 0849d38 | 2009-07-14 20:06:22 +0000 | [diff] [blame] | 195 | else |
Fariborz Jahanian | 393612e | 2009-07-21 22:36:06 +0000 | [diff] [blame] | 196 | Actions.ActOnDefaultCtorInitializers(LM.D); |
Fariborz Jahanian | d01c915 | 2009-07-14 18:24:21 +0000 | [diff] [blame] | 197 | |
Chris Lattner | 40e9bc8 | 2009-03-05 00:49:17 +0000 | [diff] [blame] | 198 | // FIXME: What if ParseConstructorInitializer doesn't leave us with a '{'?? |
| 199 | ParseFunctionStatementBody(LM.D); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 200 | } |
Douglas Gregor | 6569d68 | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 201 | |
| 202 | for (unsigned I = 0, N = Class.NestedClasses.size(); I != N; ++I) |
| 203 | ParseLexedMethodDefs(*Class.NestedClasses[I]); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /// ConsumeAndStoreUntil - Consume and store the token at the passed token |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 207 | /// container until the token 'T' is reached (which gets |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 208 | /// consumed/stored too, if ConsumeFinalToken). |
Douglas Gregor | 3f08d18 | 2008-11-10 16:59:40 +0000 | [diff] [blame] | 209 | /// If EarlyAbortIf is specified, then we will stop early if we find that |
| 210 | /// token at the top level. |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 211 | /// Returns true if token 'T1' or 'T2' was found. |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 212 | /// NOTE: This is a specialized version of Parser::SkipUntil. |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 213 | bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2, |
| 214 | CachedTokens &Toks, |
| 215 | tok::TokenKind EarlyAbortIf, |
| 216 | bool ConsumeFinalToken) { |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 217 | // We always want this function to consume at least one token if the first |
| 218 | // token isn't T and if not at EOF. |
| 219 | bool isFirstTokenConsumed = true; |
| 220 | while (1) { |
| 221 | // If we found one of the tokens, stop and return true. |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 222 | if (Tok.is(T1) || Tok.is(T2)) { |
| 223 | if (ConsumeFinalToken) { |
| 224 | Toks.push_back(Tok); |
| 225 | ConsumeAnyToken(); |
| 226 | } |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 227 | return true; |
| 228 | } |
| 229 | |
Douglas Gregor | 3f08d18 | 2008-11-10 16:59:40 +0000 | [diff] [blame] | 230 | // If we found the early-abort token, return. |
| 231 | if (Tok.is(EarlyAbortIf)) |
| 232 | return false; |
| 233 | |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 234 | switch (Tok.getKind()) { |
| 235 | case tok::eof: |
| 236 | // Ran out of tokens. |
| 237 | return false; |
| 238 | |
| 239 | case tok::l_paren: |
| 240 | // Recursively consume properly-nested parens. |
| 241 | Toks.push_back(Tok); |
| 242 | ConsumeParen(); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 243 | ConsumeAndStoreUntil(tok::r_paren, tok::unknown, Toks); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 244 | break; |
| 245 | case tok::l_square: |
| 246 | // Recursively consume properly-nested square brackets. |
| 247 | Toks.push_back(Tok); |
| 248 | ConsumeBracket(); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 249 | ConsumeAndStoreUntil(tok::r_square, tok::unknown, Toks); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 250 | break; |
| 251 | case tok::l_brace: |
| 252 | // Recursively consume properly-nested braces. |
| 253 | Toks.push_back(Tok); |
| 254 | ConsumeBrace(); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 255 | ConsumeAndStoreUntil(tok::r_brace, tok::unknown, Toks); |
Argyrios Kyrtzidis | 4cc18a4 | 2008-06-24 22:12:16 +0000 | [diff] [blame] | 256 | break; |
| 257 | |
| 258 | // Okay, we found a ']' or '}' or ')', which we think should be balanced. |
| 259 | // Since the user wasn't looking for this token (if they were, it would |
| 260 | // already be handled), this isn't balanced. If there is a LHS token at a |
| 261 | // higher level, we will assume that this matches the unbalanced token |
| 262 | // and return it. Otherwise, this is a spurious RHS token, which we skip. |
| 263 | case tok::r_paren: |
| 264 | if (ParenCount && !isFirstTokenConsumed) |
| 265 | return false; // Matches something. |
| 266 | Toks.push_back(Tok); |
| 267 | ConsumeParen(); |
| 268 | break; |
| 269 | case tok::r_square: |
| 270 | if (BracketCount && !isFirstTokenConsumed) |
| 271 | return false; // Matches something. |
| 272 | Toks.push_back(Tok); |
| 273 | ConsumeBracket(); |
| 274 | break; |
| 275 | case tok::r_brace: |
| 276 | if (BraceCount && !isFirstTokenConsumed) |
| 277 | return false; // Matches something. |
| 278 | Toks.push_back(Tok); |
| 279 | ConsumeBrace(); |
| 280 | break; |
| 281 | |
| 282 | case tok::string_literal: |
| 283 | case tok::wide_string_literal: |
| 284 | Toks.push_back(Tok); |
| 285 | ConsumeStringToken(); |
| 286 | break; |
| 287 | default: |
| 288 | // consume this token. |
| 289 | Toks.push_back(Tok); |
| 290 | ConsumeToken(); |
| 291 | break; |
| 292 | } |
| 293 | isFirstTokenConsumed = false; |
| 294 | } |
| 295 | } |